mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-28 02:04:41 +00:00
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 |
||
|---|---|---|
| .. | ||
| app | ||
| console | ||
| containers | ||
| desktop | ||
| desktop-electron | ||
| docs | ||
| enterprise | ||
| extensions/zed | ||
| function | ||
| identity | ||
| opencode | ||
| plugin | ||
| script | ||
| sdk | ||
| shared | ||
| slack | ||
| storybook | ||
| ui | ||
| web | ||