bytecodealliance / javy

JS to WebAssembly toolchain
Apache License 2.0
2.06k stars 99 forks source link

Embedding in Node.js Application throws using precompiled binaries #694

Closed guest271314 closed 2 days ago

guest271314 commented 2 days ago

Operating system: ... Linux Processor architecture: ... x86_64 GNU/Linux Rust version: ... Javy version: ... 3.0.0

Problem

Download javy-x86_64-linux-v3.0.0.gz and javy-quickjs_provider.wasm.gz.

Complete steps here Embedding in Node.js Application ...

node --no-warnings=ExperimentalWarning --experimental-wasi-unstable-preview1 --no-warnings --experimental-default-type=module host.js TypeError: WebAssembly.instantiate(): Import #0 module="javy_quickjs_provider_v2": module is not an object or function at runJavy (file:///home/user/bin/host.js:56:40) at async file:///home/user/bin/host.js:11:18 ...

The extracted file is named "javy_quickjs_provider_wizened.wasm" if javy is looking for "javy_quickjs_provider_v2"?

saulecabrera commented 2 days ago

We could improve the way we are generating the name of the build assets so that the provider file is versioned accordingly and it the relationship between javy version and provider version is explicit.

The example could be fixed by correctly renaming the provider instance import:

const instance = await WebAssembly.instantiate(embeddedModule, {
  javy_quickjs_provider_v2: providerInstance.exports,
});
guest271314 commented 2 days ago

We could improve the way we are generating the name of the build assets so that the provider file is versioned accordingly and it the relationship between javy version and provider version is explicit.

A "nightly" or "latest" option would be useful, to avoid having to keep up with changing versions, and to run the lastest developer version of the code.

In the meantime the documentation can be updated to explain what's going on and what is expected for the files in releases.

The example could be fixed by correctly renaming the provider instance import:

const instance = await WebAssembly.instantiate(embeddedModule, {
javy_quickjs_provider_v2: providerInstance.exports,
});

That works.