refactor(build): migrate tsup → tsdown#2513
Merged
Merged
Conversation
.nvmrc was 22.15.0 → 24.16.0 and the CI surface moved to a Node 22.x/24.x unit-test matrix some time ago; CLAUDE.md still claimed 22.15.0 + Node 18/20, which is wrong on both counts.
tsup 8.5.1's DTS plugin unconditionally injects `baseUrl: "."` into the compiler options it hands to rollup-plugin-dts. TypeScript 6.0 rejects that with TS5101, blocking the root TS bump (see #2491). The workaround in tests.yml only patched the test-types matrix and not the build job — piling more workarounds on a deprecated bundler is the wrong direction. tsdown is rolldown-based, uses rolldown-plugin-dts (no baseUrl injection), declares peer typescript ^5 || ^6, and tsup's own README recommends it. What changes: - tsup.config.base.ts → tsdown.config.base.mjs (+ matching .d.mts). JS + JSDoc rather than TS so the per-package tsdown.config.ts files load it through the native ESM loader; pnpm's strict isolation collides with tsdown's tsx loader. - All 12 per-package tsup.config.ts → tsdown.config.ts. - Each package's build/dev scripts swap tsup → tsdown and pre-clean dist/ (tsdown's clean defaults differ). - Drop the now-dead test-types '6.0' jq patch + comment block. The six-bundle layout (cjs dev + prod-min and esm legacy + modern + modern.dev + modern.prod-min) is preserved byte-for-byte at the file listing level — packages' public `exports` fields are unchanged. Known behaviour difference: for the modern.mjs entry (the one carrying .d.mts), rolldown extracts its `__exportAll` runtime helper into a sibling dist/chunk.mjs that codeSplitting:false does not suppress in tsdown 0.22 / rolldown 1.0. The chunk ships via each package's `files: ["dist/**/*"]` and is resolved as a relative import from the entry, so consumers are unaffected; are-the-types-wrong is green across all resolution modes for the produced tarballs. Refs: egoist/tsup#1388.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
tsup8.5.1's DTS plugin unconditionally injectsbaseUrl: "."into the compiler options it hands torollup-plugin-dts. TypeScript 6.0 rejects that with TS5101 ("Option 'baseUrl' is deprecated"), which is what blocked #2491. The existingignoreDeprecationspatch intests.ymlonly covers thetest-typesmatrix entry — thebuildjob has none. Stacking more workarounds on a deprecated bundler is the wrong direction.tsdownis rolldown-based, usesrolldown-plugin-dts(nobaseUrlinjection — verified against the plugin source), declares peertypescript: "^5.0.0 || ^6.0.0", and tsup's own README recommends the migration. Our Node floor already clears tsdown 0.22's^22.18.0 || >=24.0.0requirement, so no Node bump rides along.Upstream tracking: egoist/tsup#1388.
Known behaviour difference
For each package's
modern.mjsentry (the one carrying the canonical.d.mts), rolldown extracts its__exportAllruntime helper into a siblingdist/chunk.mjs.codeSplitting: falsedoes not suppress this in tsdown 0.22 / rolldown 1.0. The chunk ships via each package'sfiles: ["dist/**/*"]and is resolved as a relative import from the entry, so consumers are unaffected —arethetypeswrongis green across all four resolution modes (node10,node16 from CJS,node16 from ESM,bundler) for the produced tarballs.