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
14 changes: 7 additions & 7 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.6",
"typescript": "7.0.2",
"vite": "^8.3.0",
"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.6",
"solid-element": "^1.9.2",
"solid-js": "^1.9.15",
"tailwindcss": "^4.1.13",
Expand Down
23 changes: 11 additions & 12 deletions js/common/vite-plugin-worklet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { build } from "esbuild";
import { rolldown } from "rolldown";
import type { Plugin } from "vite";

const SUFFIX = "?worklet";
Expand All @@ -8,7 +8,7 @@ const SUFFIX = "?worklet";
*
* Usage: import workletUrl from "./my-worklet.ts?worklet"
*
* The worklet file is compiled to JS with all dependencies bundled via esbuild,
* The worklet file is compiled to JS with all dependencies bundled via rolldown,
* then inlined as a string. At runtime, a blob URL is created and exported.
* Pass the URL to audioWorklet.addModule().
*/
Expand Down Expand Up @@ -36,16 +36,15 @@ export function workletInline(alias?: Record<string, string>): Plugin {
this.addWatchFile(filePath);
}

const result = await build({
entryPoints: [filePath],
bundle: true,
write: false,
format: "esm",
target: "esnext",
alias: alias,
});

const compiled = result.outputFiles[0].text;
// Rolldown is Vite's own bundler and runs in-process, so nothing outlives the build.
const bundle = await rolldown({ input: filePath, platform: "browser", resolve: { alias } });
let compiled: string;
try {
const { output } = await bundle.generate({ format: "es", codeSplitting: false });
compiled = output[0].code;
} finally {
await bundle.close();
}

return [
`const code = ${JSON.stringify(compiled)};`,
Expand Down
29 changes: 29 additions & 0 deletions js/common/worklet.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { expect, test } from "bun:test";
import { spawnSync } from "node:child_process";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { build } from "vite";
import { workletInline } from "./vite-plugin-worklet";

// 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: [workletInline()],
build: {
outDir,
lib: { entry: resolve(import.meta.dir, "../watch/src/audio/decoder.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/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fix:
# Run all unit tests.
test:
bun install --frozen-lockfile
bun test common/declarations.test.ts common/deps.test.ts
bun test common/declarations.test.ts common/deps.test.ts common/worklet.test.ts
bun run --filter='*' --elide-lines=0 test

# Run one net benchmark: broadcasts, forward, reader, frames, track, varint, or lite-varint.
Expand Down
2 changes: 1 addition & 1 deletion js/moq-boy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"//devDependencies": "These are only needed for local development with workspace packages. They are NOT needed when using the published npm packages.",
"devDependencies": {
"@types/bun": "^1.4.2",
"esbuild": "^0.28.2",
"rimraf": "^6.1.3",
"rolldown": "^1.2.6",
"solid-js": "^1.9.15",
"typescript": "7.0.2",
"vite": "^8.3.0",
Expand Down
2 changes: 1 addition & 1 deletion js/publish/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,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.6",
"typescript": "7.0.2",
"vite": "^8.3.0"
}
Expand Down
2 changes: 1 addition & 1 deletion js/watch/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.6",
"typescript": "7.0.2",
"vite": "^8.3.0"
}
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.6",
"vite": "^8.3.0"
}
}
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.6",
"vite": "^8.3.0"
}
}
Loading