bun:bundle Runtime Shim
- Entity ID:
ent-20260420-b01a00000002 - Type:
file - Scope:
shared - Status:
active - Aliases: bun-bundle.ts shim, src/shims/bun-bundle.ts, feature() runtime
Description
Runtime replacement for Bun's build-time bun:bundle module that exposes a feature(name) function. In original Bun builds, feature('X') is replaced with a boolean constant at bundle time and dead-code-eliminated; without the bundler the import resolves to nothing. The shim (at src/shims/bun-bundle.ts) reads feature flags from environment variables with sensible defaults, enabling dev builds via esbuild to keep the same source code. Enumerates 11 flags: PROACTIVE, KAIROS, BRIDGE_MODE, DAEMON, VOICE_MODE, AGENT_TRIGGERS, MONITOR_TOOL, COORDINATOR_MODE, ABLATION_BASELINE (always off external), DUMP_SYSTEM_PROMPT, BG_SESSIONS.
Key claims
- Claude Code shipped depending on Bun's bundler for compile-time feature stripping
- Eleven feature flags gate runtime behavior in the bun:bundle shim
- esbuild replaces Bun's bundler for rebuild via three targeted overrides
- tsconfig paths handles bun:bundle type-checking while esbuild handles runtime resolution
Relations
- bun:bundle Runtime Shim --[contained_in]--> src/shims Directory
- esbuild Build System (scripts/build-bundle.ts) --[aliases]--> bun:bundle Runtime Shim
- bun:bundle Runtime Shim --[replaces]--> Bun DCE Feature-Gate Pattern
- bun:bundle Runtime Shim --[implements]--> Feature Flags (Build-Time)
- Tool Registry Gating Taxonomy --[uses]--> bun:bundle Runtime Shim
- Feature Flag Environment Variable Namespace --[configures]--> bun:bundle Runtime Shim
- tsconfig.json bun:bundle Path Mapping --[type_stubs_for]--> bun:bundle Runtime Shim