#pack #workflow #tool

bin+lib wasm-pack

๐Ÿ“ฆโœจ your favorite rust -> wasm workflow tool!

13 releases (7 breaking)

0.8.1 Apr 4, 2019
0.7.0 Mar 16, 2019
0.5.1 Oct 9, 2018
0.4.2 Jul 25, 2018
0.1.0 Mar 16, 2018

#28 in WebAssembly

Download history 288/week @ 2018-12-21 158/week @ 2018-12-28 193/week @ 2019-01-04 225/week @ 2019-01-11 279/week @ 2019-01-18 234/week @ 2019-01-25 187/week @ 2019-02-01 364/week @ 2019-02-08 261/week @ 2019-02-15 337/week @ 2019-02-22 340/week @ 2019-03-01 441/week @ 2019-03-08 488/week @ 2019-03-15 507/week @ 2019-03-22 434/week @ 2019-03-29

1,430 downloads per month


2.5K SLoC

๐Ÿ“ฆโœจ wasm-pack

Your favorite rust -> wasm workflow tool!

Build Status Build status crates.io

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 rust-generated WebAssembly packages that you could publish to the npm registry, or otherwise use alongside any javascript packages in workflows that you already use, such as webpack or greenkeeper.

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


๐Ÿ”ฎ Prerequisities

This project requires Rust 1.30.0 or later.

๐ŸŽ™๏ธ Commands

  • build: Generate an npm wasm pkg from a rustwasm crate
  • test: Run browser tests
  • pack and publish: Create a tarball of your rustwasm pkg and/or publish to a registry

๐Ÿ“ Logging

wasm-pack uses env_logger to produces logs when wasm-pack runs.

To configure your log level, use the RUST_LOG environment variable. For example:

RUST_LOG=info wasm-pack build

๐Ÿ‘ฏ Contributing

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

๐Ÿคนโ€โ™€๏ธ Governance

This project is part of the [rustwasm Working Group].

This project was started by [ashleygwilliams] and is co-maintained by [ashleygwilliams], [drager] and the Rust Wasm Working Group Core Team.

โšก 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:
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 build, 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.


~364K SLoC