Claude
Cursor
Skill
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.
Virus-scanned
Reviewed automatically before listing.
Download
goldziher-ai-rulez-internal_builtins_bindings_wasm_skills_wasm-bindings-ca967ad.zip · 0 KB
Install
skills CLI
npx skills add https://github.com/Goldziher/ai-rulez/tree/main/internal/builtins/bindings/wasm/skills/wasm-bindings
Claude Code
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install goldziher-ai-rulez@llmmart
Git
git clone https://github.com/Goldziher/ai-rulez.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole goldziher/ai-rulez collection as a plugin from our marketplace. Git is the plain clone.
Skill manifest
- 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).
Files (ai-rulez)
-
SKILL.md 1.3 KB
--- 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." --- - Use `wasm-bindgen` for JavaScript interop. Use `wasm-pack` for building and packaging. - Map Rust types to JS with `#[wasm_bindgen]`. Use `JsValue` for 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-futures` for Promise-returning functions. Never block the main thread. - Bundle size: use `opt-level = "z"`, `lto = true`, `codegen-units = 1` in release profile. - Use `web-sys` and `js-sys` for Web API access. Feature-gate platform-specific APIs. - Test with `wasm-pack test --headless --firefox` and a JS test runner (e.g., Vitest or Jest) for JS integration tests. - Generate TypeScript definitions automatically. Keep `.d.ts` files in sync with Rust exports. - Anti-patterns: no `std::thread` (single-threaded), no synchronous I/O, no panics (becomes JS exception).
Comments (0)
Sign in to join the conversation.
Reviews (0)
No reviews yet.
No comments yet.