Created
November 27, 2017 00:28
-
-
Save apiraino/ecaf05e427746bfdc7daa1f7fa37c50b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### install deps | |
Reference here: https://medium.com/@ianjsikes/get-started-with-rust-webassembly-and-webpack-58d28e219635 | |
### create a binary rust project | |
### write a public function | |
### compile Rust code targeting WASM | |
wargo build (i.e. cargo build --target=wasm32-unknown-emscripten) | |
### test binary | |
cd target/wasm32-unknown-emscripten/debug/ | |
node meow.js | |
### get all boiletplate to compile using NodeJS | |
create webpack.config.js | |
create package .json | |
create src/index.js (that includes wasm code) | |
create index.html (that includes build/bundle.js) | |
### compile and run using NodeJS | |
``` | |
npm install | |
npm run compile | |
npm run serve | |
``` | |
# wasm-gc | |
``` | |
$ rustup update nightly | |
$ rustup target add wasm32-unknown-unknown --toolchain nightly | |
$ rustc +nightly --target wasm32-unknown-unknown -O .\add.rs --crate-type=cdylib | |
$ cargo install --git https://github.com/alexcrichton/wasm-gc | |
$ wasm-gc .\add.wasm small-add.wasm | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment