Project Templates - Rust and WebAssembly (original) (raw)
- 1. Introduction
- 2. Why Rust and WebAssembly?
- 3. Background And Concepts
- 4. Tutorial
- 5. Reference
- 5.1. Crates You Should Know
- 5.2. Tools You Should Know
- 5.3. Project Templates
- 5.4. Debugging
- 5.5. Time Profiling
- 5.6. Shrinking .wasm Size
- 5.7. JavaScript Interoperation
- 5.8. Which Crates Will Work Off-the-Shelf with WebAssembly?
- 5.9. How to Add WebAssembly Support to a General-Purpose Crate
- 5.10. Deploying Rust and WebAssembly to Production
Rust and WebAssembly
The Rust and WebAssembly working group curates and maintains a variety of project templates to help you kickstart new projects and hit the ground running.
This template is for starting a Rust and WebAssembly project to be used with wasm-pack.
Use cargo generate
to clone this project template:
cargo install cargo-generate
cargo generate --git https://github.com/rustwasm/wasm-pack-template.git
This template is for JavaScript projects that consume packages from npm that were created from Rust with wasm-pack.
Use it with npm init
:
mkdir my-project
cd my-project/
npm init wasm-app
This template is often used alongside wasm-pack-template
, wherewasm-pack-template
projects are installed locally with npm link
, and pulled in as a dependency for a create-wasm-app
project.
This template comes pre-configured with all the boilerplate for compiling Rust to WebAssembly and hooking that directly into a Webpack build pipeline with Webpack's rust-loader.
Use it with npm init
:
mkdir my-project
cd my-project/
npm init rust-webpack