From 61d91ad7168cf8a0c3b9a81e8ebb94b25064d529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E7=8E=AE=E6=96=87?= Date: Sat, 23 May 2026 21:00:32 +0800 Subject: [PATCH] fix(build): tree-shake React reconciler dev build to prevent PerformanceMeasure leak (#4462) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ink 6→7 upgrade (v0.15.11) pulled in react-reconciler 0.33, whose development build calls performance.measure() on every component render. Since NODE_ENV was never set to "production" in the esbuild define map, the bundle shipped both dev and prod builds and selected dev at runtime, causing an unbounded measureEntryBuffer leak (~45% of heap after moderate use, confirmed via heap snapshots). Set process.env.NODE_ENV to "production" at build time so esbuild statically resolves the conditional require and tree-shakes the entire 15k-line dev build. Bundle shrinks by ~700 KB / 15,800 lines. --- esbuild.config.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/esbuild.config.js b/esbuild.config.js index a842a2c6b9..bc50dc265e 100644 --- a/esbuild.config.js +++ b/esbuild.config.js @@ -112,6 +112,11 @@ esbuild }, define: { 'process.env.CLI_VERSION': JSON.stringify(pkg.version), + // react-reconciler ≥0.33 (ink 7) gates its dev build behind NODE_ENV + // and calls performance.measure() on every render, leaking + // PerformanceMeasure objects into the global measureEntryBuffer. + // Setting production here tree-shakes the entire dev build (~15k lines). + 'process.env.NODE_ENV': JSON.stringify('production'), // Make global available for compatibility global: 'globalThis', // Redirect free __dirname/__filename references to the shim so that