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
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 16 additions & 6 deletions scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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}.`)
Expand Down
Loading