Skip to content

WebAssembly

WebAssembly CI on GitHub Actions

The wasm toolchain installs and the Rust or C++ side rebuilds every run.

90s → 4s
Toolchain setup
7m → 90s
Build

The wasm toolchain installs and the Rust or C++ side rebuilds every run.

Why it happens

wasm-pack, emsdk and the target-specific build directories are not cached.

What to change

  1. Cache the emsdk or wasm32 target directory keyed on the toolchain version
  2. Cache the Cargo target directory for the wasm32 target separately from native
  3. Run wasm-opt as a separate step so it can be skipped in pull requests

WebAssembly on runnerhut

yaml
jobs:
build:
runs-on: runnerhut-8vcpu-ubuntu-2404
steps:
- uses: actions/checkout@v4
- run: rustup target add wasm32-unknown-unknown
- run: wasm-pack build --release
A working starting point

The only runnerhut-specific line is `runs-on: runnerhut-8vcpu-ubuntu-2404`. Everything else is standard GitHub Actions — the same actions, the same secrets and the same permissions model you use today.

Your next build could be twice as fast, at half the price

Start free. Migrating away is the same one line, and we publish that diff too.