Question: how to specify the wasm path in the generated js file?
In the generated js file there's
return fetch( "main.wasm", {credentials: "same-origin"} )
is there a way to customize the wasm path (like "wasm/main.wasm")?
also is there a way to remove the
console.log( "Finished loading Rust wasm module 'main'" );
part (or like omit it in like production mode)?
Currently this is not customizable, however you can use --runtime=library-es6 argument to generate a .js file which you can load manually yourself. (It exports two things - imports and initialize. You need to load the WASM module yourself and pass the imports when instantiating it, and then use initialize on the instantiated module.)
@slmjkdbtl To be more specific, you would do something like this:
import init from "./path/to/js";
const wasm = init();
WebAssembly.instantiateStreaming(fetch("path/to/wasm"), wasm.imports).then((result) => {
const exports = wasm.initialize(result.instance);
});
@koute @Pauan Thank you, very helpful! But will there be an option to specify such thing in the future?