bun build --compile fails if dependency uses wasm
What version of Bun is running?
1.0.6+969da088f5db3258a803ec186012e30f992829b4
What platform is your computer?
macos Darwin 22.6.0 arm64 arm
What steps can reproduce the bug?
Install a node module like ink that has wasm in it
bun install ink
Add it to an index.ts
console.log(await import('ink'))
It will fail
What is the expected behavior?
Should work
What do you see instead?
➜ minimal-bun-repro bun start $ bun build ./index.ts --compile --outfile mycli && ./mycli [29ms] bundle 112 modules [88ms] compile mycli
error: Cannot find module "./yoga.wasm" from "compi
Additional information
Minimal repro here [email protected]:roninjin10/minimal-bun-repro.git
git clone [email protected]:roninjin10/minimal-bun-repro.git
cd minimal-bun-repro
bun install
bun start
Hi, is there any update on this? I'm running into the same issue.
With same example I am seeing this issue:
$ bun build --compile index.ts
6 | import devtools from 'react-devtools-core';
^
error: Could not resolve: "react-devtools-core". Maybe you need to "bun install"?
at /Users/gtrabanco/MyProjects/bun-5657/node_modules/ink/build/devtools.js:6:22
Bun revision: 1.1.5-canary.1+b257a3097
I'm seeing that error as well, but it goes away if you bun add react-devtools-core --dev.
Anyone find any workarounds for this? This is still an issue on 1.1.10.
I'm running 1.1.15 and the issue stills there.
Cannot find module "./yoga.wasm" from "/$bunfs/root/sample-ink"
1.1.17 The same captures this issue
same
my workaround
cp ./node_modules/yoga-wasm-web/dist/yoga.wasm ./dist/yoga.wasm
Having same issue.
Cannot find module "./yoga.wasm" from "/$bunfs/root/sample-ink"
Still seeing this issue in 1.1.26
See https://github.com/oven-sh/bun/issues/15639#issuecomment-2525337240
Working solution to embed yoga wasm into single file executable: https://github.com/oven-sh/bun/issues/13405#issuecomment-2613977616
Having the same issue with mupdfjs
failed to asynchronously prepare wasm: Error: ENOENT: no such file or directory, open '/$bunfs/root/mupdf-wasm.wasm'
warning: Loading from a file URI (file:///$bunfs/root/mupdf-wasm.wasm) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing
Aborted(Error: ENOENT: no such file or directory, open '/$bunfs/root/mupdf-wasm.wasm')
309 | if (process["argv"].length > 1) {
310 | thisProgram = process["argv"][1].replace(/\\/g, "/");
311 | }
312 | arguments_ = process["argv"].slice(2);
313 | process["on"]("uncaughtException", function(ex) {
314 | throw ex;
^
RuntimeError: Aborted(Error: ENOENT: no such file or directory, open '/$bunfs/root/mupdf-wasm.wasm')
I'm running into this issue with @cwasm/nsbmp (a dependency of one of my project's dependencies). When running the compiled single file executable on my raspberry pi, I see the following error:
ENOENT: no such file or directory, open '/home/runner/work/tiny-fax-service/tiny-fax-service/node_modules/@cwasm/nsbmp/nsbmp.wasm'
path: "/home/runner/work/tiny-fax-service/tiny-fax-service/node_modules/@cwasm/nsbmp/nsbmp.wasm",
syscall: "open",
errno: -2,
code: "ENOENT"
at <anonymous> (/$bunfs/root/tf_printer:2:11853)
at <anonymous> (/$bunfs/root/tf_printer:2:346)
at /$bunfs/root/tf_printer:17:509
Bun v1.2.14 (Linux arm64)
From what I'm reading in this issue thread and similar ones, it doesn't look like there are any available workarounds in my particular case but I'd be more than happy to try out any suggestions!
Possible workaround: upgrade to the latest version of Ink & React.
I can confirm that this did not work in Ink 4.4.1, but as of Ink 5 and Ink 6 it does work. Please let us know if you continue to run into issues when using Ink in Bun
Thanks @Jarred-Sumner !