Build System & Dead Code Elimination
Overview
Claude Code uses Bun for building with a sophisticated dead code elimination (DCE) system. The binary size matters - we need to exclude internal features from external builds.
Plain text
┌─────────────────────────────────────────────────────────────────────────────┐
│ BUILD PIPELINE │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Source │───►│ Bun │───►│ Binary │ │
│ │ (TypeScript)│ │ Bundle │ │ (compiled) │ │
│ └──────────────┘ └──────┬──────┘ └──────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ BUILD PHASES │ │
│ │ │ │
│ │ 1. TRANSPILE TypeScript → JavaScript (SWC) │ │
│ │ 2. TREE SHAKE Remove unused code │ │
│ │ 3. MACRO EVAL Evaluate feature() at build time │ │
│ │ 4. BUNDLE Single file output │ │
│ │ 5. MINIFY Compress & optimize │ │
│ │ 6. COMPILE Native binary (bun build --compile) │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘