js2
js2 copied to clipboard
WASI node:fs now imports env::__extern_get?
Describe the bug
--target wasai is now creating a .js file and importing "env" "__extern_get" when importing node:fs
To Reproduce
bun ~/localscripts/*js2wasm/node_modules/@loopdive/js2/src/cli.ts nm_bun_sync_stream.ts --no-dts --no-wat -O4 --target=wasi --no-host-imports --emulate=none -o ./output
/media/user/output/nm_bun_sync_stream.wasm (23122 bytes)
/media/user/output/nm_bun_sync_stream.imports.js (1876 chars)
To run: wasmtime -W gc=y,function-references=y,tail-call=y,exceptions=y /media/user/output/nm_bun_sync_stream.wasm
Expected behavior
No .js file to be generated, and no imports expected in WASI P1 context beside wasi_snapshot_preview1.
--no-host-import and --emulate node did not used to be necessary for WASI P1.
The WASM binary fails to execute
~/bin/nm_standalone_test.js ./output/nm_js2wasm_sync_stream.sh
{
path: "./output/nm_js2wasm_sync_stream.sh",
allowed_origin: undefined
}
Testing ./output/nm_js2wasm_sync_stream.sh Native Messaging host
Error: failed to run main module `./output/nm_js2wasm_sync_stream.wat`
Caused by:
0: failed to instantiate "/output/nm_js2wasm_sync_stream.wat"
1: unknown import: `env::__extern_get` has not been defined
I figured it out.