-
BackgroundI'm compiling multiple programs to Wasm and want to run them with the same Node.js-based runner script, my setup is similar to the following. The generated Wasm binary should import a print function
This generates a Wasm module expecting a function import under the name QuestionIs there an option so I currently use a script to get rid of that, which works but is a bit unpleasant, Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I'm not aware of extern "C" {
fn write_string(s: &str);
} Obviously this has a lot of problems. Why exactly do you need the imported name not to change? |
Beta Was this translation helpful? Give feedback.
I'm not aware of
wasm-bindgen
supporting this.To circumvent
wasm-bindgen
you could just use Rust directly:Obviously this has a lot of problems.
Why exactly do you need the imported name not to change?
The reason why
wasm-bindgen
generates a shim is because e.g.&str
isn't FFI safe and isn't compatible with JS, so this function can't really be exposed through Wasm in the first place.