Your favorite rust -> wasm workflow tool!
9351 blockquote>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!
init
: Generate an npm wasm pkg from a rustwasm cratepack
: Create a tarball of your rustwasm pkgpublish
: Publish your rustwasm pkg to a registryWe generate a
wasm-pack.log
file ifwasm-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 Read our guide on getting up and running for developing
wasm-pack
, and check out our contribution policy.
- Write a crate in Rust.
- Add
wasm-bindgen
to yourCargo.toml
:[lib] crate-type = ["cdylib"] [dependencies] wasm-bindgen = "0.2"
- Add this to the top of your
src/lib.rs
:#![feature(proc_macro, wasm_import_module, wasm_custom_section)] extern crate wasm_bindgen; use wasm_bindgen::prelude::*;
- Annotate your public functions with
#[wasm_bindgen]
, for example:#[wasm_bindgen] extern { pub fn alert(s: &str); } #[wasm_bindgen] pub fn greet(name: &str) { alert(&format!("Hello, {}!", name)); }
- Install this tool:
cargo install wasm-pack
- Run
wasm-pack init
, optionally, pass a path to a dir or a scope (see above for details)- This tool generates files in a
pkg
dir- To publish to npm, run
wasm-pack publish
. You may need to login to the registry you want to publish to. You can login usingwasm-pack login
.`
forked from rustwasm/wasm-pack
-
Notifications
You must be signed in to change notification settings - Fork 0
📦✨ your favorite rust -> wasm workflow tool!
License
Apache-2.0, MIT licenses found
Licenses found
Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
xeqlol/wasm-pack
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
📦✨ your favorite rust -> wasm workflow tool!
Resources
License
Apache-2.0, MIT licenses found
Licenses found
Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Code of conduct
Stars
Watchers
Forks
Packages 0
No packages published
Languages
- Rust 100.0%