perf: add Rollup tree-shaking pre-pass for export * as barrels
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
This commit is contained in:
parent
7341718f92
commit
d1a9ef8053
5 changed files with 211 additions and 1 deletions
1
bun.lock
1
bun.lock
|
|
@ -450,6 +450,7 @@
|
|||
"@typescript/native-preview": "catalog:",
|
||||
"drizzle-kit": "catalog:",
|
||||
"drizzle-orm": "catalog:",
|
||||
"rollup": "4.60.1",
|
||||
"typescript": "catalog:",
|
||||
"vscode-languageserver-types": "3.17.5",
|
||||
"why-is-node-running": "3.2.2",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue