rust-wasm

Build, test, and shrink Rust WebAssembly artifacts for browser, Node.js, and WASI hosts.

2|1|Updated Aug 19, 2026
One-click install
npx skills add https://github.com/po4yka/rust-skills --skill rust-wasm-po4yka
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: rust-wasm
Source: https://github.com/po4yka/rust-skills/tree/main/skills/rust-wasm
Command: npx skills add https://github.com/po4yka/rust-skills --skill rust-wasm-po4yka

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Rust compiled to WebAssembly fails in production when the target triple, host runtime, engine feature baseline, or artifact format (core module vs component) does not match the actual deployment environment. This Skill provides target selection tables, triage guides for instantiation and link failures, and verification matrices so wasm builds work on the exact host that runs them. ## Core Features & Use Cases - Target and host selection: Maps host contracts (browser, Node.js, WASIp1, WASIp2, Component Model, wasm32v1-none) to the correct Rust target triple with constraints for each. - Failure triage: Diagnoses unknown imports, undefined symbols, getrandom compile errors, wasm-bindgen version mismatches, wasm-opt feature rejections, and time/panic traps on wasm32-unknown-unknown. - Verification matrix: Defines four test layers including wasm-pack browser/Node.js tests, wasm-tools validate against engine baselines, and packaged artifact size budgets. - Use Case: A team shipping a Rust parsing library to both browsers and a wasmtime-based WASI host uses this Skill to pick wasm32-unknown-unknown and wasm32-wasip2 targets, configure getrandom backends, and validate each artifact against its engine baseline in CI. ## Quick Start Ask the agent to set up and verify a Rust WebAssembly build for your target host, for example to fix a wasm-bindgen instantiation failure or shrink a packaged wasm binary.

Frequently Asked Questions about rust-wasm

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I choose between wasm32-unknown-unknown and wasm32-wasip1?▼

Choose wasm32-unknown-unknown for browser or JavaScript hosts with explicit imports, and wasm32-wasip1 for existing WASI Preview 1 runtimes. The unknown target has no WASI imports, so std::fs fails and std::time panics there, while wasip1 provides wasi_snapshot_preview1 imports.

How to fix getrandom compile_error on wasm32-unknown-unknown?▼

getrandom has no default backend on wasm32-unknown-unknown, so enable the wasm_js feature for version 0.3.4+ or 0.4, or the js feature for 0.2. Set it in the final cdylib or binary crate, never in a library, since it breaks non-JavaScript WebAssembly builds.

Why does wasm-bindgen report a Wasm file schema version error?▼

This error means the wasm-bindgen CLI version differs from the locked wasm-bindgen crate version in Cargo.lock. Compare wasm-bindgen --version with Cargo.lock and install the exact locked CLI version, or build through wasm-pack which handles the match automatically.

Does Rust WebAssembly support threads and Tokio multi-thread runtime?▼

WebAssembly threads require host support, shared memory, worker setup, and HTTP isolation headers in browsers, so a successful +atomics compile proves nothing about runtime conditions. Do not enable a multi-thread Tokio runtime for ordinary browser WebAssembly; use host Promise and timer APIs instead.

Why does wasm-opt reject bulk-memory instructions from Rust builds?▼

Rust 1.87+ emits bulk-memory and non-trapping float-to-int instructions by default, which older wasm-opt configurations reject. Enable both features explicitly in the wasm-opt arguments under package.metadata.wasm-pack, and pin the wasm-pack and binaryen versions in CI.

How do I validate a wasm module for an old WebAssembly 1.0 engine?▼

Run wasm-tools validate with --features=wasm1 or wasm2, since plain validate accepts every phase 4 proposal and proves nothing about old engines. For WebAssembly 1.0 engines, build with wasm32v1-none on stable or rebuild std with -Ctarget-cpu=mvp on nightly.