diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ad5325..b33e899 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,8 +53,10 @@ All notable changes to this project are documented here. The format is based on `packages/shared/src/modes.ts`. - Release build: `onnxruntime-node` (pulled in by the on-device mic via `@huggingface/transformers`) ships no darwin/x64 prebuilt, which broke the - `darwin-x64` binary build and blocked the release. It is now marked external - for that target only; the mic's lazy import degrades gracefully on Intel Macs. + `darwin-x64` binary build and blocked the release. It is now stubbed to `{}` + for that target only (a `--compile` standalone can't resolve an external + runtime require), so the binary builds and Transformers.js falls back to its + WASM backend; the mic degrades gracefully on Intel Macs. ## [2.0.2] - 2026-06-18 diff --git a/scripts/build.ts b/scripts/build.ts index 353cb74..e18466c 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -195,13 +195,23 @@ for (const t of targets) { // mic) ships no darwin/x64 prebuilt — its bin/napi-v6/ has darwin/arm64 only. // Its binding.js does `require(`../bin/napi-v6/${platform}/${arch}/…node`)`, // so bundling on the Intel-mac runner can't resolve darwin/x64 and the build - // fails. Mark it external there: the binary still builds, and the mic's lazy - // `import("@huggingface/transformers")` (mic.ts) catches the missing module - // and degrades gracefully — Intel Macs can't run the native runtime anyway. - const external = t.name === "darwin-x64" ? ["onnxruntime-node"] : undefined + // fails. `external` doesn't help (a --compile standalone binary has no + // node_modules to resolve a runtime require → "Cannot find package"). Instead + // stub the package to {} for darwin-x64 only: nothing reaches the missing + // .node, the binary builds, and Transformers.js falls back to its WASM + // backend (onnxruntime-web), so the mic still degrades gracefully there. + const plugins = [solidTransformPlugin] + if (t.name === "darwin-x64") { + plugins.push({ + name: "stub-onnxruntime-node", + setup(b) { + b.onResolve({ filter: /^onnxruntime-node$/ }, () => ({ path: "onnxruntime-node", namespace: "ort-node-stub" })) + b.onLoad({ filter: /.*/, namespace: "ort-node-stub" }, () => ({ contents: "export default {}", loader: "js" })) + }, + }) + } const result = await Bun.build({ entrypoints: [ENTRY], - external, compile: { target: t.bun as Bun.Build.CompileTarget, outfile: outBase, @@ -213,7 +223,7 @@ for (const t of targets) { define: { __FRIDAY_VERSION__: JSON.stringify(VERSION), }, - plugins: [solidTransformPlugin], + plugins, }) if (!result.success) { console.error(`\nbuild failed for ${t.name}.`)