Skip to content

build: migrate from tsup to tsdown - #162

Merged
cawalch merged 1 commit into
mainfrom
build/migrate-to-tsdown
Nov 1, 2026
Merged

cawalch merged 1 commit into
mainfrom
build/migrate-to-tsdown

Conversation

@cawalch

@cawalch cawalch commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

Replace tsup with tsdown. The published artifacts are unchanged, the dependency tree shrinks by 39 packages, and the TypeScript 7 blocker goes away.

• Add tsdown.config.ts mapping the seven existing builds one-for-one: CJS/ESM for index and stream, CJS/ESM for the CLI with the shebang banner, and ESM/IIFE browser bundles with minified variants.
• Keep the output layout identical — all 26 files keep their names (index.cjs, index.mjs, index.d.ts, index.d.cts, index.esm.js, index.esm.min.js, index.umd.js, index.umd.min.js, stream.*, cli.*, and their maps). Declarations are pinned explicitly to .d.ts for ESM and .d.cts for CJS because tsdown defaults to .d.mts.
• Remove tsup, tsup.config.ts, and the tsup → esbuild@^0.28.2 override. tsdown has no esbuild dependency, so esbuild disappears from the tree and the earlier GHSA-g7r4-m6w7-qqqr workaround is no longer needed.
• Remove the stale esbuild entry from allowScripts; fsevents remains approved.
• Pin tsdown to ~0.23.4 because it is still pre-1.0.

Why now: typescript@7 removed the compiler API that rollup-plugin-dts uses, and tsup still bundles it (upstream #1405 and #1408 are open). tsdown uses rolldown-plugin-dts, which supports TypeScript 7.

Verification

On Node.js 26.13.0:

  • Artifact parity: diff of the ls dist output before (tsup) and after (tsdown) is empty — 26/26 identical filenames.
  • npm test -- test/build-artifacts.spec.ts — 21/21 passed, including CJS/ESM interop, default exports, the IIFE global shape (var jmespath = (function), source maps, declaration contents, and the CLI shebang.
  • Manual runtime check of dist/index.umd.js in a VM: jmespath.search({a:1}, 'a') and jmespath.default.search(...) both return 1; dist/index.esm.js exposes named and default exports.
  • npm test — 1,380 tests passed; npm run coverage — same thresholds and percentages as before (statements 95.66%, branches 91.93%, functions 95.83%, lines 95.54%).
  • npm run lint:ci — passes.
  • npm audit — 0 vulnerabilities; osv-scanner — "No issues found".
  • npm pack --dry-run — 29 files, 2.33 MB unpacked (2.85 MB with tsup); the lockfile drops from 307 to 180 packages.

The CI matrix (22.x/24.x/26.x), the OSV workflows, and verify-lockfile all run on this pull request. Do not merge before the CI run completes — this changes the build toolchain.

Next

typescript@7 can be attempted immediately after this lands; it was closed in #158 only because tsup could not generate declarations with it.

Replace the esbuild-based bundler with tsdown, which is built on Rolldown and supports TypeScript 7.

• Add `tsdown.config.ts` reproducing the seven existing builds: CJS and ESM for the library, stream and CLI entries, plus ESM and IIFE browser bundles with minified variants.
• Keep the published artifact set stable: the same 26 files with the same names, shebang, source maps and declarations.
• Remove `tsup`, `tsup.config.ts` and the `tsup` → `esbuild` override; dropping tsup also removes esbuild from the tree entirely.
• Explain declaration extensions explicitly (`index.d.ts` for ESM, `index.d.cts` for CJS) so the output matches the previous layout.
• Drop the now-unused `esbuild` entry from `allowScripts`.
@cawalch
cawalch merged commit 2174078 into main Nov 1, 2026
9 checks passed
@cawalch
cawalch deleted the build/migrate-to-tsdown branch November 1, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant