build: replace tsup with tsdown and make the published types reachable - #167
Merged
Conversation
There was a problem hiding this comment.
Code Review
This pull request replaces the build tool tsup with tsdown, updating the build and dev scripts in package.json and adding a new tsdown.config.ts configuration file. It also updates the package exports to explicitly define type definitions. A critical issue was identified in the tsdown.config.ts file where the configuration option outExtensions is misspelled as plural instead of singular (outExtension). This typo would cause the option to be ignored, resulting in .mjs output files that break the package exports pointing to .js files.
tsup 8.5.1 inlines its own `rollup-plugin-dts@6.1.1` compiled against `typescript@5.7.3`, and that vendored copy throws on TypeScript 7: TypeError: Cannot read properties of undefined (reading 'useCaseSensitiveFileNames') Nothing in our lockfile reaches it, so no `overrides` can fix it, and tsup has not published since 2025-11-12 - ~10 months, with 8.5.1 the only dist-tag. That is what blocks #145. tsdown is the rolldown-based successor from the same ecosystem, last published 2026-09-03. It emits declarations through TypeScript itself (`Emit types with typescript@7.0.2`) rather than a pinned copy of rollup-plugin-dts, which is structurally why it is not exposed to this class of breakage. While here: the declarations we were already building were unreachable. package.json had no `types` field and no `types` condition in `exports`, so no TypeScript consumer could resolve them. Added both, so the emit we are paying for is now usable. Config notes: - `outExtensions` pins .js. tsdown defaults to .mjs, which would break `bin` (./dist/cli.js) and `exports` (./dist/index.js). - dist gains .map files tsup did not emit, because tsdown forces sourcemaps on whenever tsconfig sets `declarationMap`, which ours does. They are not published - `files` already excludes `dist/**/*.map`. Verified with `npm pack --dry-run`. Verified: build succeeds on typescript 6.0.3 and 7.0.2, the built CLI runs (`node ./dist/cli.js --help`), and the packed tarball contains cli.js, index.js, both .d.ts files and schema.graphql with no maps. Lint, format and 53 files / 345 tests pass. Bundle is slightly smaller (94 kB vs 105 kB). Alternative to the --dts drop on build/drop-unused-dts - that branch unblocks TS 7 by removing declaration emit entirely. Pick one, not both.
dawsontoth
force-pushed
the
build/migrate-to-tsdown
branch
from
September 11, 2026 15:27
865e3b8 to
9df6926
Compare
|
🎉 This PR is included in version 0.16.54 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
1 task
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 move
tsup 8.5.1 inlines its own
rollup-plugin-dts@6.1.1compiled againsttypescript@5.7.3, and that vendored copy throws on TS 7 — the blocker on #145:Nothing in our lockfile reaches that copy, so
overridescan't help. And tsup is effectively dormant:tsdown is the rolldown-based successor from the same ecosystem. The relevant difference isn't that it's newer — it's that it emits declarations through TypeScript itself:
rather than through a pinned copy of
rollup-plugin-dts. That's the structural reason it isn't exposed to this class of breakage.Bonus fix: the types were unreachable
Worth knowing regardless of which branch you take — the declarations we already build can't be resolved by anyone:
This PR adds both, so the emit we're paying for is actually usable:
Config notes
outExtensionspins.js. tsdown defaults to.mjs, which would breakbin(./dist/cli.js) andexports(./dist/index.js). Caught this the first time through.dist/gains.mapfiles that tsup didn't emit. tsdown forces sourcemaps on whenever tsconfig setsdeclarationMap, which ours does — asourcemap: falsein the config does not override it. They aren't published:filesalready excludesdist/**/*.map, confirmed withnpm pack --dry-run.Verification
npm run buildPacked tarball contains exactly
cli.js,index.js,AgentManager-*.js, both.d.ts, andschema.graphql— no maps, 59.8 kB. Lint, format, and 53 files / 345 tests pass. Bundle is slightly smaller than tsup's (94 kB vs 105 kB).🤖 Generated with Claude Code