Clear and concise description of the problem
Hey! This is a feature request to add support for wasm-bindgen, a library to facilitate high-level interactions between Wasm modules and JavaScript for Rust.
wasm-bindgen has several output formats for generating Wasm <-> JS glue code, which most notably are web and bundler. I was hoping that the bundlertarger would be compatible with Vitejs, but unfortunately it's not. The output for the bundler target roughly looks like this:
// app.js
import * as wasm from "./app_bg.wasm";
export * from "./app_bg.js";
// app_bg.js
import * as wasm from './app_bg.wasm';
// ...
export function myWasmFunction() {
wasm.myWasmFunction();
}
for this code:
async function main() {
const wasmModule = await import('./app');
wasmModule.myWasmFunction();
Suggested solution
There should be an alternative way to bundle Wasm files, which also supports dynamic import function. Probably add this as an option to the serve and build command or if possible auto detect.
Alternative
No response
Additional context
No response
Validations
Clear and concise description of the problem
Hey! This is a feature request to add support for wasm-bindgen, a library to facilitate high-level interactions between Wasm modules and JavaScript for Rust.
wasm-bindgen has several output formats for generating Wasm <-> JS glue code, which most notably are
webandbundler. I was hoping that thebundlertarger would be compatible with Vitejs, but unfortunately it's not. The output for thebundlertarget roughly looks like this:for this code:
Suggested solution
There should be an alternative way to bundle Wasm files, which also supports dynamic
importfunction. Probably add this as an option to theserveandbuildcommand or if possible auto detect.Alternative
No response
Additional context
No response
Validations