fix: 添加 ignoreDCEAnnotations 修复 Bun 1.3.x barrel 优化导致的运行时崩溃

Bun 1.3.10+ 对 sideEffects:false 的包(lodash-es, @growthbook/growthbook)
启用了自动 barrel 优化,过度 tree-shaking 导致 default export 声明被移除,
运行时报 ReferenceError: default169 is not defined。
设置 ignoreDCEAnnotations: true 禁用此行为。

Ref: https://github.com/oven-sh/bun/issues/27709

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This commit is contained in:
chenqg
2026-04-03 10:41:00 +08:00
co-authored by Claude Opus 4.6
parent c901db8159
commit b9273538ca
3 changed files with 8798 additions and 7531 deletions
+1
View File
@@ -56,6 +56,7 @@ const result = await Bun.build({
format: 'esm',
sourcemap: 'linked',
minify: false,
ignoreDCEAnnotations: true, // Disable aggressive tree-shaking of sideEffects:false packages (lodash-es, @growthbook/growthbook) — fixes Bun 1.3.x barrel optimization bug
define,
external: [
// Only mark packages as external if they are:
Vendored
+8795 -7529
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
File diff suppressed because one or more lines are too long