implementing-jsc-classes-rust
Installation
SKILL.md
Contains Shell Commands
This skill contains shell command directives (!`command`) that may execute system commands. Review carefully before installing.
Bun's JavaScriptCore Class Bindings Generator
Bridge JavaScript and Rust through .classes.ts definitions and Rust implementations.
src/codegen/bindgen.ts (*.bind.ts, docs/project/bindgen.mdx) is replacing this generator: typed arguments, and the struct stored inside the JS object. Use it for a class whose struct only the JS object owns. It does not do ref-counted or shared structs, hasPendingActivity, estimatedSize or writing to a cached getter's slot yet.
Architecture
- JavaScript Interface Definition (
.classes.tsfiles) - Rust Implementation (
.rsfiles) - Generated Code —
src/codegen/generate-classes.tsemits C++ + Rust into${BUN_CODEGEN_DIR}/generated_classes.rs,include!d ascrate::generated_classesinbun_runtime. Runbun bdto regenerate.