Create your first WebAssembly npm package
If you’re curious about WebAssembly
probably you’ve heard of Rust and wasm-bingen.
Basically, with wasm-bingen you’re able to easily transform your Rust into WebAssembly
and interop between Rust and JavaScript and the other way around.
A few months ago, wasm-pack entered into the scene with the promise of making really easy the process of creating WebAssembly
npm packages. And it works. But yet web developers who are not really familiar with all the Rust ecosystem have to deal with installing Rust, setting the proper toolchain, install the wasm32-unknown-unknown
target, cargo-generate
…
Introducing wasm-pack-npm
That’s why I created wasm-pack-npm. To make all this dependency installation a breeze.
The only thing that you have to do is this:
npm i -g wasm-pack-npm
What you’ll get
wasm-pack will check if you have already a Rust installation in your computer and will proceed to install it in case it’s not present.
The same will happen for wasm-pack.
At the moment of writing this post, wasm-pack will only work with beta
or nightly
toolchain so wasm-pack will set the nightly
toolchain as your default and then will install the wasm32-unknown-unknown target.
Finally, as a nice to have, it will install cargo-generate for you.
Once you have everything set up, just head to the wasm-pack documentation to learn more about how to proceed. In less than 1o minutes I bet you’ll have your first WebAssembly
npm package ready!