When I started messing arround with Rust and webassembly I found the good Rust documentation, however it did not cover everything that I needed. In particular I had a really bad time getting wasm to run inside a test environment. After many hours of relentless and merciless battle I managed to get it to work. This is a template repository with the basic boiler-plate.
There is pretty much nothing about unit testing hybrid js/wasm code in the internet (at least that I could find). So I hope this can be helpful to somebody ;)
Any questions/suggestions feel free to open an issue/pull request.
- Clone this repo
- Have the rust toolchain installed
- Have wasm-pack installed
- Run
yarn install
. If you dont have it, you can get it here - Run
wasm-pack build
- Run
yarn link
inside thepkg
folder - Run
yarn link ilovewasm
on the project root (this is the project name on the config.toml file) - Run
yarn run dev-server
- Go to
http://localhost:8080/
To run the test suite do the steps 1 to 7 above and then:
- Run
yarn runtest-server
- Go to
http://localhost:8080/test.html
Checkout this for a simple (yet complete) tutorial of how to make a Conway's Game of Life using rust/wasm and some javascript. A more indepth and broad tutorial is available here.
This is available under the MIT-0 license. See LICENSE for more information.
TLDR: Use it for whatever you wan't, don't bother with attribution.