oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
71.09k stars 2.47k forks source link

Crash when building a file that imports a wasm file #10873

Open pfgithub opened 1 week ago

pfgithub commented 1 week ago

How can we reproduce the crash?

# Create wasm file
touch a.zig
zig build-exe a.zig -target wasm32-freestanding -fno-entry -femit-bin=a.wasm
# Create bun file
echo 'import a from "./a.wasm";' > a.js
echo 'console.log(a);' >> a.js

Crashes:

bun build --target=bun a.js

Outputs the filename, rather than a WebAssembly.Module as documentation would suggest:

bun a.js

JavaScript/TypeScript code that reproduces the crash?

import a from "./a.wasm";
console.log(a);

Relevant log output

============================================================
Bun v1.1.7 (b0b7db5c) macOS Silicon
Args: "bun", "build", "--target=bun", "a.js"
Elapsed: 24ms | User: 6ms | Sys: 13ms
RSS: 13.12MB | Peak: 13.12MB | Commit: 1.07GB | Faults: 292

panic(main thread): Internal error: missing asset file
oh no: Bun has crashed. This indicates a bug in Bun, not your code.

To send a redacted crash report to Bun's team,
please file a GitHub issue using the link below:

 https://bun.report/1.1.7/Mb1b0b7db5AA2+jpnC23innC+uu/mCm8l3B2+04B+j/9BmwoB+wa__A0eNrzzCtJLcpLzFFILSrKL7JSyM0sLs7MS1dILC5OLVFIy8xJBQDiFgzc

fish: Job 1, 'bun build --target=bun a.js' terminated by signal SIGTRAP (Trace or breakpoint trap)
Exited with code [SIGTRAP]

Stack Trace (bun.report)

Bun v1.1.7 (b0b7db5) on macos aarch64 [BuildCommand]

panic: Internal error: missing asset file