#pack #publish #npm

bin wasm-pack

pack up the wasm and publish it to npm!

7 unstable releases (3 breaking)

0.4.2 Jul 25, 2018
0.4.1 Jul 14, 2018
0.4.0 Jun 18, 2018
0.3.1 Jun 5, 2018
0.1.0 Mar 16, 2018

#17 in WebAssembly

Download history 25/week @ 2018-05-27 74/week @ 2018-06-03 91/week @ 2018-06-10 61/week @ 2018-06-17 78/week @ 2018-06-24 71/week @ 2018-07-01 37/week @ 2018-07-08 70/week @ 2018-07-15 86/week @ 2018-07-22 88/week @ 2018-07-29 80/week @ 2018-08-05 90/week @ 2018-08-12 89/week @ 2018-08-19

256 downloads per month

📦✨ wasm-pack

Your favorite rust -> wasm workflow tool!

Build Status Build status

This tool seeks to be a one-stop shop for building and working with rust- generated WebAssembly that you would like to interop with JavaScript, in the browser or with Node.js. wasm-pack helps you build and publish rust-generated WebAssembly to the npm registry to be used alongside any other javascript package in workflows that you already use, such as a bundler like webpack or greenkeeper.

This project is a part of the rust-wasm group. You can find more info by visiting that repo!


🔮 Prerequisities

🎙️ Commands

  • init: Generate an npm wasm pkg from a rustwasm crate
  • pack: Create a tarball of your rustwasm pkg
  • publish: Publish your rustwasm pkg to a registry

📝 Logging

We generate a wasm-pack.log file if wasm-pack errors on you, and you can customize the log verbosity using the verbosity flag.

Verbosity Result
-v All Info, Warn, and Errors are logged
-vv All Debug, Info, Warn, and Errors are logged
-vvv All Trace, Debug, Info, Warn, and Errors are logged

👯 Contributing

Read our guide on getting up and running for developing wasm-pack, and check out our contribution policy.

⚡ Quickstart Guide

  1. Write a crate in Rust.
  2. Add wasm-bindgen to your Cargo.toml:
crate-type = ["cdylib"]

wasm-bindgen = "0.2"
  1. Add this to the top of your src/lib.rs:

extern crate wasm_bindgen;

use wasm_bindgen::prelude::*;
  1. Annotate your public functions with #[wasm_bindgen], for example:
extern {
    pub fn alert(s: &str);

pub fn greet(name: &str) {
    alert(&format!("Hello, {}!", name));
  1. Install this tool: cargo install wasm-pack
  2. Run wasm-pack init, optionally, pass a path to a dir or a scope (see above for details)
  3. This tool generates files in a pkg dir
  4. To publish to npm, run wasm-pack publish. You may need to login to the registry you want to publish to. You can login using wasm-pack login.
MIT/Apache-2.0 license


Reverse deps