tsdown and tsup are development tools designed to bundle TypeScript libraries into distributable JavaScript packages. They handle compilation, minification, and type definition generation, allowing developers to publish modern, compatible code to npm without managing complex build configurations manually. tsup is a mature, widely-adopted solution powered by esbuild, known for its speed and stability. tsdown is a newer entrant built on top of rolldown (a Rust-based Rollup implementation), aiming to provide similar developer experience with potential performance gains and Rollup plugin compatibility.
Both tsdown and tsup solve the same core problem: compiling TypeScript libraries into distributable JavaScript packages for npm. They remove the need for manual webpack or rollup configurations, offering zero-config defaults that work for most projects. However, they differ significantly in their underlying engines and plugin ecosystems. Let's compare how they handle the build process.
tsup is built on top of esbuild, a Go-based bundler known for extreme speed.
# tsup: Uses esbuild under the hood
npx tsup src/index.ts
tsdown is built on top of rolldown, a Rust-based implementation of Rollup.
# tsdown: Uses rolldown under the hood
npx tsdown
The choice of engine dictates which plugins you can use. This is often the deciding factor for complex projects.
tsup supports esbuild plugins.
// tsup.config.ts
import { defineConfig } from 'tsup';
export default defineConfig({
entry: ['src/index.ts'],
esbuildPlugins: [
// Custom esbuild plugin
myEsbuildPlugin()
]
});
tsdown supports rollup plugins.
// tsdown.config.ts
import { defineConfig } from 'tsdown';
import replace from '@rollup/plugin-replace';
export default defineConfig({
entry: ['src/index.ts'],
plugins: [
// Native Rollup plugin support
replace({ values: { __VERSION__: '1.0.0' } })
]
});
Both tools aim for zero-config usage, but allow customization via config files.
tsup uses tsup.config.ts.
// tsup.config.ts
export default {
entry: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
splitting: false,
clean: true
};
tsdown uses tsdown.config.ts.
tsup users.// tsdown.config.ts
export default {
entry: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
clean: true
};
Generating TypeScript definition files (.d.ts) is critical for library authors.
tsup uses tsup's built-in dts bundler (often leveraging rollup-plugin-dts internally).
// tsup: Enable dts generation
export default {
dts: true, // Generates .d.ts files
dtsResolve: true // Resolves external types
};
tsdown integrates type generation directly into the rolldown pipeline.
// tsdown: Enable dts generation
export default {
dts: true // Generates .d.ts files
};
Despite the engine differences, both tools share a common philosophy of simplifying library development.
npx without a config file.# Both work with simple CLI commands
npx tsup src/index.ts
npx tsdown
// Both support format arrays
format: ['cjs', 'esm', 'iife']
# Both support watch flag
npx tsup --watch
npx tsdown --watch
// Both support clean option
clean: true
dependencies and peerDependencies as external.// Both handle externals automatically based on package.json
// No extra config needed for standard deps
| Feature | Shared by tsdown and tsup |
|---|---|
| Purpose | ๐ฆ TS Library Bundling |
| Config | ๐ TypeScript Config Files |
| Outputs | ๐ CJS, ESM, IIFE |
| Types | ๐ก๏ธ d.ts Generation |
| DX | โก Watch Mode, CLI |
| Externals | ๐ Auto-externalize deps |
| Feature | tsup | tsdown |
|---|---|---|
| Engine | ๐น Esbuild (Go) | ๐ฆ Rolldown (Rust) |
| Plugins | ๐ Esbuild Plugins | ๐ Rollup Plugins |
| Maturity | ๐ข Stable, Industry Standard | ๐ก Emerging, Bleeding Edge |
| Ecosystem | ๐ฅ Large Community | ๐ฑ unjs / Vite Ecosystem |
| Config Name | tsup.config.ts | tsdown.config.ts |
| Primary Goal | Reliability & Speed | Future-proofing & Compatibility |
tsup is the safe, reliable choice ๐ก๏ธ. It has powered thousands of libraries for years. If you need a build tool that just works today with minimal risk, tsup is the answer. The esbuild plugin ecosystem is sufficient for 90% of use cases.
tsdown is the forward-looking choice ๐ญ. It bets on the Rust-based future of JavaScript tooling. If you need specific Rollup plugins that esbuild doesn't support, or you want to align with the unjs ecosystem, tsdown is worth exploring. However, be prepared for occasional updates as the tool matures.
Final Thought: For most production libraries today, tsup remains the default recommendation due to its stability. Keep an eye on tsdown as the rolldown engine reaches version 1.0 โ it may well become the new standard for performance and compatibility.
Choose tsdown if you want to leverage the emerging rolldown engine for potential performance improvements or need compatibility with Rollup plugins instead of esbuild plugins. It is suitable for early adopters, projects within the unjs ecosystem, or teams willing to track bleeding-edge tooling for faster build times and future-proofing.
Choose tsup if you need a stable, battle-tested bundler with a large ecosystem of esbuild plugins. It is the industry standard for TypeScript library authors who prioritize reliability, extensive documentation, and community support. It is ideal for production projects where build consistency and long-term maintenance are critical.
โจ The elegant bundler for libraries powered by Rolldown.
For full documentation, visit tsdown.dev.
npm i -D tsdown
npx tsdown
This project is licensed under the MIT License.