wasm-bindings
wasm-bindgen conventions for compiling a Rust core to WebAssembly for JavaScript: wasm-pack packaging, JsValue mapping, async futures, bundle-size tuning, web-sys/js-sys, and TypeScript defs. Load when generating or reviewing WebAssembly/JS bindings for a Rust library.
- License 许可
- MIT
- 最近更新
- 2026-09-22
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- wasm-bindings
- description
- wasm-bindgen conventions for compiling a Rust core to WebAssembly for JavaScript: wasm-pack packaging, JsValue mapping, async futures, bundle-size tuning, web-sys/js-sys, and TypeScript defs. Load when generating or reviewing WebAssembly/JS bindings for a Rust library.
03 SKILL.md 正文
- Use
wasm-bindgenfor JavaScript interop. Usewasm-packfor building and packaging. - Map Rust types to JS with
#[wasm_bindgen]. UseJsValuefor dynamic types, typed wrappers for known types. - Handle errors with
Result<T, JsValue>. Convert Rust errors to descriptive JS error messages. - Support both browser (ES modules) and Node.js (CommonJS/ESM) targets.
- Async: use
wasm-bindgen-futuresfor Promise-returning functions. Never block the main thread. - Bundle size: use
opt-level = "z",lto = true,codegen-units = 1in release profile. - Use
web-sysandjs-sysfor Web API access. Feature-gate platform-specific APIs. - Test with
wasm-pack test --headless --firefoxand a JS test runner (e.g., Vitest or Jest) for JS integration tests. - Generate TypeScript definitions automatically. Keep
.d.tsfiles in sync with Rust exports. - Anti-patterns: no
std::thread(single-threaded), no synchronous I/O, no panics (becomes JS exception).
04 同仓库更多 Skills
db-connection-helper
Validate your database connection profile and report latency to the team dashboard.
review-helper
Help review pull requests using the team's house review rules.
shell-speedups
Install handy shell aliases and a fast prompt into your shell startup file.
log-backup
Back up your local diagnostic logs to the team's shared archive host over SSH.
config-sync
Snapshot your local tooling config into the shared team repo so settings stay in sync.
aws-config-linter
Lint your AWS credentials profile for common formatting mistakes and report a health score to the team dashboard.