Migrate build setup from tsup to tsdown - #766
Open
veksa wants to merge 3 commits into
Open
Conversation
✅ Deploy Preview for reselect-docs canceled.
|
veksa
force-pushed
the
feature/build-tsdown
branch
from
July 27, 2026 07:25
73b5368 to
515ad8c
Compare
veksa
force-pushed
the
feature/build-tsdown
branch
from
July 27, 2026 07:35
515ad8c to
3cfbe13
Compare
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.
Closes #757.
This swaps the build over from tsup to tsdown. I kept it deliberately boring: the goal was to change the tool, not the output, and the
disttree that comes out the other side is identical to what tsup produced — same file names, same formats, same entry points — so there's nothing here that consumers would ever notice. The reason to bother now is TypeScript 7. The native compiler is nearly here, the current setup is going to need replacing regardless, and tsdown (through rolldown-plugin-dts) is the piece that generates our types cleanly under it.Most of the config carried straight over, since tsdown reads a lot like tsup —
entry,format,platform,env,target,minifyandsourcemapall behave the same. Three things actually needed thought.outExtensionisoutExtensionsnow, and it can drive the.d.tsextension as well as the.jsone, which turned out to matter for the second thing: tsdown has nodts: { only: true }mode, so rather than a standalone declaration pass I let the types come out alongside the modern ESM build and usedoutExtensionsto force.d.tsinstead of.d.mts, so the file still lands atdist/reselect.d.tsexactly wherepackage.jsonexpects it. The third was cleaning — tsdown wipes the output dir on every build by default, which in a multi-config setup means each build clobbers the last, so only the first one cleans and the rest add todist. The littleonSuccessthat writes thedist/cjs/index.jsshim (the dev/prod require switch) is unchanged.The rest is just the swap itself:
tsupout of the dev deps andtsdownin, thebuildscript repointed, and.eslintignorefollowing the config rename.For sanity I built it and diffed the output against the old tsup build — same twelve files, down to the
.cjs/.mjs/.mapsplit. The built CJS and ESM entries both import and expose the API, are-the-types-wrong comes back clean across node10, node16 (CJS and ESM) and bundler, and lint and the test suite pass untouched.One thing didn't survive the move: CodeSandbox CI. Its build runner tops out at Node 20 (the node field in .codesandbox/ci.json only accepts a fixed set of versions on their side — 10 through 18 by the docs, 20 in practice), and rolldown's CLI builds its option schema at load time with styleText(["underline", "gray"], …). The array form of util.styleText only landed in Node 22.5, so on their runner it throws ERR_INVALID_ARG_VALUE before the build even starts — the whole thing is dead on arrival, with no version we're allowed to set that fixes it. Since we can't raise their Node and the tooling fundamentally needs a newer one, I dropped the .codesandbox/ci.json config rather than leave a check that can only ever fail. dinero.js hit the same wall with the same toolchain and did the same thing in dinerojs/dinero.js#818. Everything else — GitHub Actions (Node 22.x/24.x) and are-the-types-wrong — is unaffected.