Project Templates - Rust and WebAssembly (original) (raw)

  1. 1. Introduction
  2. 2. Why Rust and WebAssembly?
  3. 3. Background And Concepts
    1. 3.1. What is WebAssembly?
  4. 4. Tutorial
    1. 4.1. Setup
    2. 4.2. Hello, World!
    3. 4.3. Rules
    4. 4.4. Implementing Life
    5. 4.5. Testing Life
    6. 4.6. Debugging
    7. 4.7. Adding Interactivity
    8. 4.8. Time Profiling
    9. 4.9. Shrinking .wasm Size
    10. 4.10. Publishing to npm
  5. 5. Reference
    1. 5.1. Crates You Should Know
    2. 5.2. Tools You Should Know
    3. 5.3. Project Templates
    4. 5.4. Debugging
    5. 5.5. Time Profiling
    6. 5.6. Shrinking .wasm Size
    7. 5.7. JavaScript Interoperation
    8. 5.8. Which Crates Will Work Off-the-Shelf with WebAssembly?
    9. 5.9. How to Add WebAssembly Support to a General-Purpose Crate
    10. 5.10. Deploying Rust and WebAssembly to Production

Rust and WebAssembly

Project Templates

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.

wasm-pack-template

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

create-wasm-app

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.

rust-webpack-template

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