From 1710c9a65d45a8b573c8cedcf280f4f65ff26114 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Date: Wed, 18 Nov 2026 14:33:37 +0300 Subject: [PATCH] fix(build): patch tsup dts cache bug that ran release builds out of memory tsup's getCompilerOptions keeps the input folder as dirName on a cache hit when a tsconfig path is passed, so rollup-plugin-dts builds a new TypeScript program per source folder. The release build of 1.0.0-alpha.131 hit the 12 GB heap limit. With the fix the declaration build takes ~9s and ~1.3 GB; API reports are unchanged. Co-Authored-By: Claude Opus 5.5 --- package.json | 2 +- scripts/patch-tsup.mjs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 scripts/patch-tsup.mjs diff --git a/package.json b/package.json index 617b7d8f9..a5681247b 100644 --- a/package.json +++ b/package.json @@ -373,7 +373,7 @@ "./dist/index.mjs" ], "scripts": { - "build": "node --max-old-space-size=12288 node_modules/tsup/dist/cli-default.js", + "build": "node scripts/patch-tsup.mjs && node --max-old-space-size=12288 node_modules/tsup/dist/cli-default.js", "dev": "node --max-old-space-size=12288 node_modules/tsup/dist/cli-default.js --watch", "pre-release": "npm version prerelease --preid=alpha --no-git-tag-version && node scripts/sync-version.mjs && npm publish --access public --tag alpha", "pre-release:create-lousho": "npm version prerelease --preid=alpha --no-git-tag-version -w create-lousho && npm run build -w create-lousho && npm publish -w create-lousho --access public --tag alpha", diff --git a/scripts/patch-tsup.mjs b/scripts/patch-tsup.mjs new file mode 100644 index 000000000..1a1be60bb --- /dev/null +++ b/scripts/patch-tsup.mjs @@ -0,0 +1,10 @@ +import { readFileSync, writeFileSync } from 'node:fs'; + +const file = 'node_modules/tsup/dist/rollup.js'; +const anchor = 'logCache("HIT", cacheKey);'; +const fix = 'if (overrideConfigPath) dirName = path__namespace.dirname(path__namespace.resolve(process.cwd(), overrideConfigPath));'; +const src = readFileSync(file, 'utf8'); +if (!src.includes(fix)) { + if (!src.includes(anchor)) throw new Error(`patch-tsup: anchor not found in ${file}; tsup changed, re-check the dts cache bug`); + writeFileSync(file, src.replace(anchor, `${anchor}\n ${fix}`)); +}