Rust+wasm without npm


I want to use the wasm backend for Rust with wasm-bindgen, but not use a nodejs server; I have a different server instead.

I’ve been following this guide.

I compiled by code successfully into a hello.wasm file. I ran wasm-bindgen successfully and got the postprocessed hello_bg.wasm and a hello.js file.

Now the guide tells me to use webpack to package these files into an ES6 module, and then import it as follows in a second js file:

const js = import("./hello");

js.then(js => {

All my attempts at creating this ./hello module from my existing files has failed. My browser is unable to import the "./hello" module.

How do I finish this final step without npm?


This needs to be documented a lot better, but I found this in the manual, listed fairly non-obviously.

1 Like

For anyone following along, that link already seems to be broken – I found what I believe is the same information here: