Native WebAssembly loader for Webpack

With the new wasm32-unknown-unknown target being available in rustc, I made a simple POC library for easily importing Rust code from Javascript (both node.js and browsers). There are other similar libraries using Emscripten that served as inspiration but I tried to keep this one quite a bit simpler in comparison.

Some tl;dr example Javascript (ES6) code:

import loadRustlib from './path/to/rustlib/src/'

loadRustlib().then(result => {
  // This is a normal #[no_mangle] Rust function: fn add(i32, i32) -> i32
  const add = result.instance.exports['add'];
  console.log('return value was', add(2, 3));

I would love some feedback on the code:

See published documentation on NPM:


Nice! I showed this to the Webpack team, and one of them asked:


Looks fine! I have a small test project and switched it to the aforementioned loader:

Edit: running yarn && yarn setup && yarn start should be enough.


I have now added both wasm-bindgen and cargo-web support to this loader! See the README for short usage instructions.