Subchapter 8.9
references/guide-migrate-from-tsup.mdMarkdown5 KBView on GitHub
tsdown is built on Rolldown (Rust-based) vs tsup’s esbuild, providing faster and more powerful bundling while maintaining compatibility.
npx tsdown-migrate# Using glob patterns
npx tsdown-migrate packages/*
# Multiple directories
npx tsdown-migrate packages/foo packages/bar[...dirs] - Directories to migrate (supports globs)--dry-run or -d - Preview changes without modifying filesImportant: Commit your changes before running migration.
| Option | tsup | tsdown |
|---|---|---|
format | ['cjs'] | ['esm'] |
clean | false | true |
dts | false | Auto-enabled if types/typings in package.json |
target | Manual | Auto-read from engines.node in package.json |
| tsup | tsdown |
|---|---|
outExtension | outExtensions |
For IIFE builds, tsdown emits [name].iife.js; tsup commonly emitted [name].global.js. outExtensions customizes extensions or suffixes, but it does not remove .iife or .umd. Use outputOptions.entryFileNames: '[name].global.js' to preserve old IIFE filenames.
export default defineConfig({
nodeProtocol: true, // Add node: prefix (fs → node:fs)
nodeProtocol: 'strip', // Remove node: prefix (node:fs → fs)
nodeProtocol: false, // Keep as-is (default)
})export default defineConfig({
workspace: 'packages/*', // Build all packages
})npx tsdown-migratetsup to tsdown in package.jsonpnpm build to verifyBefore (tsup):
export default defineConfig({
entry: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
})After (tsdown):
export default defineConfig({
entry: ['src/index.ts'],
format: ['esm', 'cjs'], // ESM now default
dts: true,
clean: true, // Now enabled by default
})Before (tsup):
export default defineConfig({
entry: ['src/index.ts'],
target: 'es2020',
})After (tsdown):
export default defineConfig({
entry: ['src/index.ts'],
// target auto-reads from package.json engines.node
// Or override explicitly:
target: 'es2020',
})Before (package.json):
{
"scripts": {
"build": "tsup",
"dev": "tsup --watch"
}
}After (package.json):
{
"scripts": {
"build": "tsdown",
"dev": "tsdown --watch"
}
}Most tsup features are supported:
Some tsup features are not yet available. Check GitHub issues (opens in a new tab) for status and request features.
target; if you need to support Node.js 18 / 20, build with Node.js 22+ in CI and test the produced output (or packed tarball) on the lower versions.tsdown should be faster than tsup. If not:
isolatedDeclarations for faster DTS generationskipNodeModulesBundle if neededtsdown is heavily inspired by tsup and incorporates parts of its codebase. Thanks to @egoist (opens in a new tab) and the tsup community.