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

  1. JavaScript Interface Definition (.classes.ts files)
  2. Rust Implementation (.rs files)
  3. Generated Code — src/codegen/generate-classes.ts emits C++ + Rust into ${BUN_CODEGEN_DIR}/generated_classes.rs, include!d as crate::generated_classes in bun_runtime. Run bun bd to regenerate.

Class Definition (.classes.ts)

Installs
28
Repository
oven-sh/bun
GitHub Stars
96.3K
First Seen
Jul 8, 2026