Problem
Two source files have organically grown to where they actively hurt navigation, incremental compile times, and reviewability:
crates/vcad-kernel-wasm/src/lib.rs — 5912 lines. All #[wasm_bindgen] surface in one file: Solid impl, primitives, sweeps, drafting, slicer cost, raytrace, embroidery, the new DFM bindings I just added. cargo build recompiles the whole file on any change, which compounds the wasm-pack bundle time.
crates/vcad-ir/src/lib.rs — 1969 lines. CsgOp enum, Node, MaterialDef, SceneEntry, EnvironmentPreset, Document, createDocument, helpers, tests — all in one file. Adding a new CsgOp variant is awkward when the enum is in the middle of a 2000-line file.
Proposed split
vcad-kernel-wasm
src/
lib.rs # crate doc + init + #[wasm_bindgen(start)] + re-exports
primitives.rs # Solid::cube/cylinder/sphere/cone + bbox + volume + COM
sweeps.rs # extrude/revolve/sweep_line/sweep_helix/loft
booleans.rs # union/difference/intersection
transforms.rs # translate/rotate/scale/mirror
features.rs # fillet/chamfer/shell/pattern
drafting.rs # section_mesh / projections / hatch
cost.rs # estimatePrintCost + estimate_cost_for_process (the new DFM-era binding)
dfm.rs # run_dfm_on_brep_json + get_default_dfm_pack + Solid::runDfm
raytrace.rs # render bindings
embroidery.rs
ecad.rs
The Solid struct stays in lib.rs; impl Solid blocks split across files (Rust allows multiple impl blocks).
vcad-ir
src/
lib.rs # crate doc + re-exports
op.rs # CsgOp enum + tool_schema attrs
node.rs # Node, NodeId
scene.rs # SceneEntry, EnvironmentPreset, scene settings
material.rs # MaterialDef
document.rs # Document, createDocument, toJson/fromJson, toVCode/fromVCode
sketch.rs # SketchSegment2D and friends
vcode.rs # already split out
vec3.rs # already split out
Why now
- The DFM PR added another ~150 lines to
vcad-kernel-wasm/src/lib.rs. The next feature will add another 100. There's no natural stopping point.
- Touching
vcad-ir/src/lib.rs for any IR change recompiles every TS workspace package via the codegen path.
- Reviewers can't grok diffs in either file without context.
Acceptance criteria
- Both files drop below 500 lines each (re-exports + crate-level docs only).
cargo build --workspace and cargo test --workspace pass unchanged.
cargo clippy --workspace -- -D warnings clean.
wasm-pack build produces a binary with the same exports (verified by diffing vcad_kernel_wasm.d.ts).
- No public API changes — this is a pure mechanical split.
References
crates/vcad-kernel-wasm/src/lib.rs — 5912 lines
crates/vcad-ir/src/lib.rs — 1969 lines
- For the WASM split, the existing
crates/vcad-kernel-wasm/src/{document_engine, keybindings, sketch_session}.rs are precedent for sibling modules
Problem
Two source files have organically grown to where they actively hurt navigation, incremental compile times, and reviewability:
crates/vcad-kernel-wasm/src/lib.rs— 5912 lines. All#[wasm_bindgen]surface in one file:Solidimpl, primitives, sweeps, drafting, slicer cost, raytrace, embroidery, the new DFM bindings I just added.cargo buildrecompiles the whole file on any change, which compounds the wasm-pack bundle time.crates/vcad-ir/src/lib.rs— 1969 lines.CsgOpenum,Node,MaterialDef,SceneEntry,EnvironmentPreset,Document,createDocument, helpers, tests — all in one file. Adding a newCsgOpvariant is awkward when the enum is in the middle of a 2000-line file.Proposed split
vcad-kernel-wasmThe
Solidstruct stays inlib.rs;impl Solidblocks split across files (Rust allows multiple impl blocks).vcad-irWhy now
vcad-kernel-wasm/src/lib.rs. The next feature will add another 100. There's no natural stopping point.vcad-ir/src/lib.rsfor any IR change recompiles every TS workspace package via the codegen path.Acceptance criteria
cargo build --workspaceandcargo test --workspacepass unchanged.cargo clippy --workspace -- -D warningsclean.wasm-pack buildproduces a binary with the same exports (verified by diffingvcad_kernel_wasm.d.ts).References
crates/vcad-kernel-wasm/src/lib.rs— 5912 linescrates/vcad-ir/src/lib.rs— 1969 linescrates/vcad-kernel-wasm/src/{document_engine, keybindings, sketch_session}.rsare precedent for sibling modules