conwaysgol2d-wasm
v0.3.0
Published
The necessary [index.html](index.html) and [index.js](index.js) files are there in this repo to serve the WebAssembly module. You can use a simple HTTP server to serve the files. For instance, if you have `npm` installed, you can use `http-server`:
Downloads
18
Readme
If you want to checkout a live demo, I've integrated this project with my other Game of Life experiments here [WIP]
Steps to run the pre-built package:
Serve the Project
The necessary index.html and index.js files are there in this repo to serve the WebAssembly module.
You can use a simple HTTP server to serve the files. For instance, if you have npm
installed, you can use http-server
:
npx http-server .
Navigate to the provided local server address in your browser to see the result.
Steps to build the project if you want to make changes:
1. Install Rust (if not already installed):
If you haven't installed Rust, you can do so by running the following command in your terminal: (for Linux and macOS)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
After installation, add Rust to your system's PATH by running:
source $HOME/.cargo/env
2. Install wasm-pack:
Once Rust is set up, you can install wasm-pack
using cargo
(the Rust package manager). Run:
cargo install wasm-pack
3. Install Required Tools
Ensure you have the Rust toolchain and wasm-pack
installed.
rustup target add wasm32-unknown-unknown
cargo install wasm-pack
5. Build the Project with wasm-pack
Use wasm-pack
to build your project and generate the necessary WebAssembly and JavaScript bindings:
wasm-pack build --target web
This command compiles your Rust code into WebAssembly and generates a pkg
directory containing the .wasm
file along with JavaScript bindings and TypeScript definitions. The --target web
flag tells wasm-pack
to generate the bindings for use in a web environment.