Skip to content

Repository files navigation

Experiments with Rust and WebAssembly

Prerequisites

Install Rust

Install Rust using rustup (the official installer):

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

After installation, restart your terminal or run:

source $HOME/.cargo/env

Verify installation:

rustc --version
cargo --version

Install WebAssembly Binary Toolkit (WABT)

WABT includes the wat2wasm tool for compiling WASM Text format (.wat) files into WASM binary (.wasm) files.

On macOS (using Homebrew):

brew install wabt

Verify installation:

wat2wasm --version

Compiling .wat files to .wasm:

# Compile a .wat file to .wasm
wat2wasm input.wat -o output.wasm

# With verbose output
wat2wasm input.wat -o output.wasm -v

Compiling .wasm files to .wat:

# Compile a .wasm file to .wat
wasm2wat input.wasm -o output.wat

# With verbose output
wasm2wat input.wasm -o output.wat -v

Install Node.js 24.11.0+

Direct WASM imports require Node.js v24.11.0+.

Using nvm (recommended):

Install nvm to manage multiple Node.js versions

# Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash

# Install Node.js 24.11.0 or later
nvm install 24.11.0
nvm use 24.11.0
nvm alias default 24.11.0

Using official installer:

Download from https://nodejs.org/ (choose version 24.11.0 or later)

Verify installation:

node --version
npm --version

Creating New Rust Projects

cargo new --vcs none my-project

For creating a library:

cargo new --lib --vcs none my-library

Formatting

Check if formatting is needed (without modifying files):

cargo fmt -- --check

Format a Rust project:

cargo fmt

About

Experimenting with Rust and WebAssembly

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages