From ccced29b4677e356d5ef32f73540f8e31a0ca190 Mon Sep 17 00:00:00 2001 From: Taras Shynkarenko Date: Fri, 13 Mar 2026 20:55:20 +0100 Subject: [PATCH] perf(build): deduplicate plugin-sdk chunks to fix ~2x memory regression MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bundle all plugin-sdk entries in a single tsdown build pass instead of 38 separate builds. The separate builds prevented the bundler from sharing common chunks, causing massive duplication (e.g. 20 copies of query-expansion, 14 copies of fetch, 11 copies of logger). Measured impact: - dist/ size: 190MB → 64MB (-66%) - plugin-sdk/ size: 142MB → 16MB (-89%) - JS files: 1,395 → 789 (-43%) - 5MB+ files: 27 → 7 (-74%) - Plugin-SDK heap cost: +1,309MB → +63MB (-95%) - Total heap (all chunks loaded): 1,926MB → 711MB (-63%) --- tsdown.config.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tsdown.config.ts b/tsdown.config.ts index 80833de2a14..1806debd474 100644 --- a/tsdown.config.ts +++ b/tsdown.config.ts @@ -116,12 +116,12 @@ export default defineConfig([ "line/template-messages": "src/line/template-messages.ts", }, }), - ...pluginSdkEntrypoints.map((entry) => - nodeBuildConfig({ - entry: `src/plugin-sdk/${entry}.ts`, - outDir: "dist/plugin-sdk", - }), - ), + nodeBuildConfig({ + // Bundle all plugin-sdk entries in a single build so the bundler can share + // common chunks instead of duplicating them per entry (~712MB heap saved). + entry: Object.fromEntries(pluginSdkEntrypoints.map((e) => [e, `src/plugin-sdk/${e}.ts`])), + outDir: "dist/plugin-sdk", + }), nodeBuildConfig({ entry: "src/extensionAPI.ts", }),