Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion demo/boy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@moq/signals": "workspace:^"
},
"devDependencies": {
"esbuild": "^0.28.2",
"rolldown": "^1.2.12",
"typescript": "7.0.2",
"vite": "^8.3.2",
"vite-plugin-solid": "^2.11.14"
Expand Down
2 changes: 1 addition & 1 deletion demo/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"devDependencies": {
"@tailwindcss/typography": "^0.5.20",
"@tailwindcss/vite": "^4.3.2",
"esbuild": "^0.28.2",
"highlight.js": "^11.12.0",
"open": "^11.0.4",
"rolldown": "^1.2.12",
"solid-element": "^1.9.2",
"solid-js": "^1.9.15",
"tailwindcss": "^4.1.13",
Expand Down
26 changes: 14 additions & 12 deletions js/common/vite-plugin-worklet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { basename } from "node:path";
import { build } from "esbuild";
import { rolldown } from "rolldown";
import type { Plugin } from "vite";

const SUFFIX = "?worklet";
Expand All @@ -18,18 +18,20 @@ const BLOB = "?worklet-blob";
export function worklet(alias?: Record<string, string>): Plugin {
let production = false;

// Rolldown is Vite's own bundler and runs in-process, so nothing outlives the build.
const compile = async (path: string) => {
const result = await build({
entryPoints: [path],
bundle: true,
write: false,
format: "esm",
target: "esnext",
// A consumer can't minify code inlined as a string, so builds do it here; dev stays readable.
minify: production,
alias: alias,
});
return result.outputFiles[0].text;
const bundle = await rolldown({ input: path, platform: "browser", resolve: { alias } });
try {
const { output } = await bundle.generate({
format: "es",
codeSplitting: false,
// A consumer can't minify code inlined as a string, so builds do it here; dev stays readable.
minify: production,
});
return output[0].code;
} finally {
await bundle.close();
}
};

return {
Expand Down
23 changes: 23 additions & 0 deletions js/common/worklet.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect, test } from "bun:test";
import { spawnSync } from "node:child_process";
import { mkdtempSync, readdirSync, readFileSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
Expand Down Expand Up @@ -41,3 +42,25 @@ test("library builds load worklets from a lazy blob or a hosted base", async ()
rmSync(outDir, { recursive: true, force: true });
}
});

// A bundler child process would outlive `vite build` and be reaped by init, so its CPU escapes the
// build's accounting and it lingers after the build.
test("builds leave no child process behind", async () => {
const outDir = mkdtempSync(join(tmpdir(), "worklet-"));
try {
await build({
configFile: false,
logLevel: "silent",
plugins: [worklet()],
build: {
outDir,
lib: { entry: resolve(import.meta.dir, "../publish/src/video/processor.ts"), formats: ["es"] },
rollupOptions: { external: (id) => id.startsWith("@moq/") },
},
});
} finally {
rmSync(outDir, { recursive: true, force: true });
}

expect(spawnSync("pgrep", ["-l", "-P", String(process.pid)], { encoding: "utf8" }).stdout).toBe("");
});
2 changes: 1 addition & 1 deletion js/publish/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"@types/audioworklet": "^0.0.100",
"@types/bun": "^1.4.2",
"@typescript/lib-dom": "npm:@types/web@^0.0.350",
"esbuild": "^0.28.2",
"rimraf": "^6.1.3",
"rolldown": "^1.2.12",
"typescript": "7.0.2",
"vite": "^8.3.2"
}
Expand Down
2 changes: 1 addition & 1 deletion js/watch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"@types/audioworklet": "^0.0.100",
"@types/bun": "^1.4.2",
"@typescript/lib-dom": "npm:@types/web@^0.0.350",
"esbuild": "^0.28.2",
"rimraf": "^6.1.3",
"rolldown": "^1.2.12",
"typescript": "7.0.2",
"vite": "^8.3.2"
}
Expand Down
2 changes: 1 addition & 1 deletion test/audio-quality/clients/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
},
"devDependencies": {
"@types/audioworklet": "^0.0.100",
"esbuild": "^0.28.2",
"playwright": "^1.63.0",
"rolldown": "^1.2.12",
"vite": "^8.3.2"
}
}
2 changes: 1 addition & 1 deletion test/interop/clients/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"@moq/watch": "workspace:*"
},
"devDependencies": {
"esbuild": "^0.28.2",
"playwright": "^1.63.0",
"rolldown": "^1.2.12",
"vite": "^8.3.2"
}
}
Loading