0.1.0 • Published 2 years ago

stably-template-wasmpack-es v0.1.0

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

A template for kick starting a Rust and WebAssembly project using wasm-pack.

Built with 🦀🕸 by The Rust and WebAssembly Working Group

Steps used to create this package:

> wasm-pack new template-wasmpack-es
updated README.md

About

📚 Read this template tutorial! 📚

This template is designed for compiling Rust libraries into WebAssembly and publishing the resulting package to NPM.

Be sure to check out other wasm-pack tutorials online for other templates and usages of wasm-pack.

🚴 Usage

🐑 Use cargo generate to Clone this Template

Learn more about cargo generate here.

wasm-pack new my-project
cd my-project

-OR-

cargo generate --git https://github.com/rustwasm/wasm-pack-template.git --name my-project
cd my-project

🛠️ Build with wasm-pack build

wasm-pack build --target web

🔬 Test in Headless Browsers with wasm-pack test

Firefox

Setup: install Firefox

wasm-pack test --headless --firefox
Chrome

Setup: download chromedriver and unzip into path. https://chromedriver.chromium.org/downloads

curl https://chromedriver.storage.googleapis.com/105.0.5195.19/chromedriver_mac64_m1.zip -o ~/Downloads/chromedriver_mac64_m1.zip
cd /opt/homebrew/bin
unzip ~/Downloads/chromedriver_mac64_m1.zip
wasm-pack test --headless --chrome
Safari

Setup: sudo safaridriver --enable

wasm-pack test --headless --safari

safaridriver has breaking bug: https://github.com/rustwasm/wasm-bindgen/issues/3004

🎁 Publish to NPM with wasm-pack publish

wasm-pack publish

🔋 Batteries Included

  • wasm-bindgen for communicating between WebAssembly and JavaScript.
  • console_error_panic_hook for logging panic messages to the developer console.
  • wee_alloc, an allocator optimized for small code size.
  • LICENSE-APACHE and LICENSE-MIT: most Rust projects are licensed this way, so these are included for you

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.