Bun's bundler (and esbuild) cannot tree-shake `export * as X from "./mod"` barrels — see evanw/esbuild#1420. Rollup can, using AST-level analysis to drop unused exports and their transitive imports. This adds a Rollup pre-pass to the build pipeline that runs before Bun's compile step. Rollup resolves internal source, eliminates dead code across the 57 `export * as` barrels, and writes tree-shaken ESM to a temp directory. Bun then compiles the pre-processed output into the final binary. - Add `script/treeshake-prepass.ts` with Bun.Transpiler-based Rollup plugin - Integrate into `script/build.ts` (skippable via `--skip-treeshake`) - Add `rollup` as devDependency - Pre-pass completes in ~5s, negligible vs full multi-platform build Current bundle savings are modest (~0.7%) because the single-entrypoint architecture means most code paths are reachable. Savings scale with: - Per-command entry points or lazy loading - Remaining 50 `export namespace` → `export * as` migrations - Future code splitting https://claude.ai/code/session_01R7zMpXjsq1R6uR7xpyJ14i |
||
|---|---|---|
| .. | ||
| bin | ||
| migration | ||
| script | ||
| specs | ||
| src | ||
| test | ||
| .gitignore | ||
| AGENTS.md | ||
| BUN_SHELL_MIGRATION_PLAN.md | ||
| bunfig.toml | ||
| Dockerfile | ||
| drizzle.config.ts | ||
| git | ||
| package.json | ||
| parsers-config.ts | ||
| README.md | ||
| sst-env.d.ts | ||
| time.ts | ||
| trace-imports.ts | ||
| tsconfig.json | ||