fix(build): stub onnxruntime-node for darwin-x64 (compile-safe)#14
Merged
Conversation
The previous `external` approach failed: a `bun --compile` standalone binary
has no node_modules to resolve a runtime require, so Bun errored at build with
"Cannot find package 'onnxruntime-node'". Stub the package to {} for darwin-x64
only via a resolver plugin — the missing darwin/x64 .node is never reached, the
binary builds, and Transformers.js falls back to its WASM backend. The mic's
guarded lazy import still degrades gracefully on Intel Macs.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Follow-up to #13. That change marked
onnxruntime-nodeexternal for darwin-x64, but abun --compilestandalone binary has no node_modules to resolve a runtime require, so the build failed withCannot find package 'onnxruntime-node'.Fix
Stub
onnxruntime-nodetoexport default {}for the darwin-x64 target only, via a Bun resolver plugin. The missingdarwin/x64.nodeis never reached, the binary builds, and Transformers.js falls back to its WASM backend (onnxruntime-web). The mic's guarded lazyimport("@huggingface/transformers")(mic.ts, wrapped in.catch) keeps it graceful on Intel Macs.Verified
Local cross-build of darwin-x64 now passes the bundle stage with no onnxruntime error and no "Cannot find package" (stops only at the x64 OpenTUI native lib, which is present on the real Intel runner). Typecheck + biome clean.
🤖 Generated with Claude Code