Building your project - Hello wasm-pack! (original) (raw)
- 1. Introduction
- 2. Quickstart
- 3. Prerequisites
- 4. Commands
- 5. Tutorials
- 6. Cargo.toml Configuration
- 7. Contributing
Hello wasm-pack!
We've written our code so now we need to build it.
We are writing a crate that should be used in the browser, so we run this in our terminal:
$ wasm-pack build
If you were writing a package that should be used in Node.js (with CommonJS modules, e.g. require
), you would run this in your terminal:
$ wasm-pack build --target nodejs
This command when run does a few things:
- It'll compile your code to wasm if you haven't already
- It'll generate a
pkg
folder with the wasm file, a JS wrapper file around the wasm, your README, and apackage.json
file.