tsdown
Bundle TypeScript and JavaScript libraries with tsdown, including declarations and multi-format builds.
Install
npx skills add https://github.com/rolldown/tsdown --skill tsdowntsdown - The Elegant Library Bundler
Blazing-fast bundler for TypeScript/JavaScript libraries powered by Rolldown and Oxc.
Runtime Requirement
tsdown requires Node.js 22.18.0 or higher to run (build-time only). However, the bundled output can target much lower Node.js versions via the target [blocked] option, so libraries built with tsdown are not locked to Node.js 22+ at runtime.
If your package needs to support Node.js 18 / 20:
- Build with Node.js 22+ in CI (e.g. set
target: 'node18'ortarget: 'node20'). - Test the built output (or the packed tarball) on the lower Node.js versions you intend to support — e.g. using a matrix job that runs the published package's tests on Node.js 18 / 20 / 22.
When to Use
- Building TypeScript/JavaScript libraries for npm
- Generating TypeScript declaration files (.d.ts)
- Bundling for multiple formats (ESM, CJS, IIFE, UMD)
- Optimizing bundles with tree shaking and minification
- Migrating from tsup with minimal changes
- Building React, Vue, Solid, or Svelte component libraries
Quick Start
Basic Configuration
Core References
For comprehensive migration assistance with complete option mappings, install the dedicated
tsdown-migrateskill:npx skills add rolldown/tsdown --skill tsdown-migrate
Build Options
Dependency Handling
Output Enhancement
Framework & Runtime Support
Common Patterns
Basic Library Bundle
Multiple Entry Points
Browser Library (IIFE/UMD)
React Component Library
Preserve Directory Structure
CI-Aware Configuration
WASM Support
Library with CSS and Sass
Standalone Executable
Cross-Platform Executable (requires @tsdown/exe)
Advanced with Hooks
Configuration Features
Multiple Configs
Export an array for multiple build configurations:
Conditional Config
Use functions for dynamic configuration:
Workspace/Monorepo
Use glob patterns to build multiple packages:
CLI Quick Reference
Best Practices
-
Always generate type declarations for TypeScript libraries:
-
Externalize dependencies to avoid bundling unnecessary code:
-
Use tree shaking for optimal bundle size:
-
Enable minification for production builds:
-
Add shims for better ESM/CJS compatibility:
-
Auto-generate package.json exports:
-
Use watch mode during development:
-
Preserve structure for utilities with many files:
-
Validate packages in CI before publishing:
Resources
- Documentation: https://tsdown.dev
- GitHub: https://github.com/rolldown/tsdown
- Rolldown: https://rolldown.rs
- Migration Guide: https://tsdown.dev/guide/migrate-from-tsup