A new RUST WASM project

As ever, just summary notes from the internet.

The real game of life starter guide

Initial frameworks etc

Installed wasm_pack to C:\Users\Jonathan.cargo\bin\wasm-pack.exe

cargo install cargo-generate

This lets us start a project from a template.

Need npm too

Now the log of what I did

My project is called rusty-lander

Below you enter the project name: rusty_lander

C:\all_dev\rust>cargo generate --git https://github.com/rustwasm/wasm-pack-template
 Project Name : rusty_lander
 Renaming project called `rusty_lander` to `rusty-lander`...
 Basedir: C:\all_dev\rust ...
 Generating template ...
[ 1/12]   Done: .appveyor.yml
[ 2/12]   Done: .gitignore
[ 3/12]   Done: .travis.yml
[ 4/12]   Done: Cargo.toml
[ 5/12]   Done: LICENSE_APACHE
[ 6/12]   Done: LICENSE_MIT
[ 7/12]   Done: README.md
[ 8/12]   Done: src\lib.rs
[ 9/12]   Done: src\utils.rs
[10/12]   Done: src
[11/12]   Done: tests\web.rs
[12/12]   Done: tests
 Moving generated files into: `C:\all_dev\rust\rusty-lander`...
 Initializing a fresh Git repository
 Done! New project created C:\all_dev\rust\rusty-lander

cd rusty-lander
rustup target add wasm32-unknown-unknown

npm init wasm-app www
cd www
npm install

cd ..
wasm-pack build

cd www

Edit the package.json, and just before the devDependencies add

  "dependencies": {
    "rusty-lander": "file:../pkg"

Where rusty-lander is the name of your project And you can delete

"hello-wasm-pack": "^0.1.0",

Then do an edit to index.js

import * as wasm from "rusty-lander";

And then do the install again

npm install
npm start

Then browse to http://localhost:8080/

Note that you should do the wasm-pack build any time you want to again build your code into the pkg dir and have npm reload the site.

wasm-pack build

For debug build to preserve symbols:

wasm-pack build --debug

Thats all folks.