cloudaxe-opencode/packages/opencode/script
Claude d1a9ef8053
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
2026-04-16 12:37:49 +00:00
..
build-node.ts app: remove min loading duration (#21655) 2026-04-09 16:29:46 +08:00
build.ts perf: add Rollup tree-shaking pre-pass for export * as barrels 2026-04-16 12:37:49 +00:00
check-migrations.ts sqlite again (#10597) 2026-02-14 04:19:02 +00:00
fix-node-pty.ts refactor(server): replace Bun serve with Hono node adapters (#18335) 2026-04-06 13:24:55 -04:00
generate.ts app: remove min loading duration (#21655) 2026-04-09 16:29:46 +08:00
postinstall.mjs fix: clean up final 16 no-unused-vars warnings (#22751) 2026-04-16 03:54:21 +00:00
publish.ts fix: resolve oxlint warnings — suppress false positives, remove unused imports (#22687) 2026-04-15 21:33:54 -04:00
schema.ts CLI perf: reduce deps (#22652) 2026-04-16 02:03:03 -04:00
treeshake-prepass.ts perf: add Rollup tree-shaking pre-pass for export * as barrels 2026-04-16 12:37:49 +00:00
unwrap-namespace.ts feat: unwrap Pty namespace to flat exports + barrel (#22719) 2026-04-16 02:21:46 +00:00
upgrade-opentui.ts upgrade opentui to 0.1.91 (#19440) 2026-03-28 15:10:59 +01:00