bun icon indicating copy to clipboard operation
bun copied to clipboard

bun build --compile fails if dependency uses wasm

Open roninjin10 opened this issue 2 years ago • 10 comments

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

roninjin10 avatar Oct 18 '23 04:10 roninjin10

Hi, is there any update on this? I'm running into the same issue.

seunggs avatar Apr 26 '24 05:04 seunggs

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

gtrabanco avatar Apr 26 '24 18:04 gtrabanco

I'm seeing that error as well, but it goes away if you bun add react-devtools-core --dev.

seunggs avatar Apr 26 '24 21:04 seunggs

Anyone find any workarounds for this? This is still an issue on 1.1.10.

marcjfj avatar May 27 '24 18:05 marcjfj

I'm running 1.1.15 and the issue stills there.

Cannot find module "./yoga.wasm" from "/$bunfs/root/sample-ink"

marviobezerra avatar Jun 20 '24 21:06 marviobezerra

1.1.17 The same captures this issue

Kutius avatar Jun 28 '24 05:06 Kutius

same

EdamAme-x avatar Jul 12 '24 00:07 EdamAme-x

my workaround

cp ./node_modules/yoga-wasm-web/dist/yoga.wasm ./dist/yoga.wasm

EdamAme-x avatar Jul 13 '24 05:07 EdamAme-x

Having same issue.

Cannot find module "./yoga.wasm" from "/$bunfs/root/sample-ink"

Leka74 avatar Aug 05 '24 21:08 Leka74

Still seeing this issue in 1.1.26

bephrem1 avatar Aug 26 '24 21:08 bephrem1

See https://github.com/oven-sh/bun/issues/15639#issuecomment-2525337240

okineadev avatar Dec 09 '24 07:12 okineadev

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')

snowfluke avatar Mar 11 '25 02:03 snowfluke

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!

FoxtrotPerry avatar May 26 '25 00:05 FoxtrotPerry

Possible workaround: upgrade to the latest version of Ink & React.

Image

Jarred-Sumner avatar Jun 21 '25 02:06 Jarred-Sumner

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

Image

Jarred-Sumner avatar Jun 21 '25 02:06 Jarred-Sumner

Thanks @Jarred-Sumner !

roninjin10 avatar Jun 21 '25 02:06 roninjin10