Skip to main content 홈 크리에이터 alovajs alova tsdown
tsdown Bundle TypeScript and JavaScript libraries with blazing-fast speed powered by Rolldown. Use when building libraries, generating type declarations, bundling for multiple formats, or migrating from tsup.
설치로 이동 Skills Marketplace 커뮤니티가 만든 AI 스킬을 발견하고 탐색하세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/alovajs/alova --skill tsdown명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
Zip 다운로드 다운로드 중... name tsdown description Bundle TypeScript and JavaScript libraries with blazing-fast speed powered by Rolldown. Use when building libraries, generating type declarations, bundling for multiple formats, or migrating from tsup.
tsdown - 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 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' or target: '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
pnpm add -D tsdown
npx tsdown
npx tsdown --config tsdown.config.ts
npx tsdown --watch
npx tsdown-migrate
Basic Configuration import { defineConfig } from 'tsdown' ;
export default defineConfig ({
entry : ['./src/index.ts' ],
format : ['esm' , 'cjs' ],
dts : true ,
clean : true
});
Core References
For comprehensive migration assistance with complete option mappings, install the dedicated tsdown-migrate skill: npx skills add rolldown/tsdown --skill tsdown-migrate
| Hooks | Lifecycle hooks for custom logic | advanced-hooks |
| Programmatic API | Build from Node.js scripts | advanced-programmatic |
| Rolldown Options | Pass options directly to Rolldown | advanced-rolldown-options |
| CI Environment | CI detection, 'ci-only' / 'local-only' values | advanced-ci |
Build Options Option Usage Reference Entry points entry: ['src/*.ts', '!**/*.test.ts']option-entry Output formats format: ['esm', 'cjs', 'iife', 'umd']option-output-format Output directory outDir: 'dist', outExtensionsoption-output-directory Type declarations dts: true, dts: { sourcemap, compilerOptions, vue }option-dts Target environment target: 'es2020', target: 'esnext'option-target Platform platform: 'node', platform: 'browser'option-platform Tree shaking treeshake: true, custom optionsoption-tree-shaking Minification minify: true, minify: 'dce-only'option-minification Source maps sourcemap: true, 'inline', 'hidden'option-sourcemap Watch mode watch: true, watch optionsoption-watch-mode Cleaning clean: true, clean patternsoption-cleaning Log level logLevel: 'silent', failOnWarn: falseoption-log-level
Dependency Handling
Output Enhancement Feature Usage Reference Shims shims: true - Add ESM/CJS compatibilityoption-shims CJS default cjsDefault: true (default) / falseoption-cjs-default Package exports exports: true - Generate exports fieldoption-package-exports CSS handling [experimental] css: { ... } — full pipeline with preprocessors, Lightning CSS, PostCSS, CSS modules, code splitting; requires @tsdown/cssoption-css CSS modules css: { modules: { localsConvention: 'camelCase' } } — scoped class names for .module.css filesoption-css CSS inject css: { inject: true } — preserve CSS imports in JS outputoption-css Unbundle mode unbundle: true - Preserve directory structureoption-unbundle Root directory root: 'src' - Control output directory mappingoption-root Executable [experimental] exe: true - Bundle as standalone executable, cross-platform via @tsdown/exeoption-exe Package validation publint: true, attw: true - Validate packageoption-lint
Framework & Runtime Support
Common Patterns
Basic Library Bundle export default defineConfig ({
entry : ['src/index.ts' ],
format : ['esm' , 'cjs' ],
dts : true ,
clean : true
});
Multiple Entry Points export default defineConfig ({
entry : {
index : 'src/index.ts' ,
utils : 'src/utils.ts' ,
cli : 'src/cli.ts'
},
format : ['esm' , 'cjs' ],
dts : true
});
Browser Library (IIFE/UMD) export default defineConfig ({
entry : ['src/index.ts' ],
format : ['iife' ],
globalName : 'MyLib' ,
platform : 'browser' ,
minify : true
});
React Component Library export default defineConfig ({
entry : ['src/index.tsx' ],
format : ['esm' , 'cjs' ],
dts : true ,
deps : {
neverBundle : ['react' , 'react-dom' ]
},
inputOptions : {
jsx : { runtime : 'automatic' }
}
});
Preserve Directory Structure export default defineConfig ({
entry : ['src/**/*.ts' , '!**/*.test.ts' ],
unbundle : true ,
format : ['esm' ],
dts : true
});
CI-Aware Configuration export default defineConfig ({
entry : ['src/index.ts' ],
format : ['esm' , 'cjs' ],
dts : true ,
failOnWarn : 'ci-only' ,
publint : 'ci-only' ,
attw : 'ci-only'
});
WASM Support import { wasm } from 'rolldown-plugin-wasm' ;
import { defineConfig } from 'tsdown' ;
export default defineConfig ({
entry : ['src/index.ts' ],
plugins : [wasm ()]
});
Library with CSS and Sass export default defineConfig ({
entry : ['src/index.ts' ],
format : ['esm' , 'cjs' ],
dts : true ,
target : 'chrome100' ,
css : {
preprocessorOptions : {
scss : {
additionalData : `@use "src/styles/variables" as *;`
}
}
}
});
Standalone Executable export default defineConfig ({
entry : ['src/cli.ts' ],
exe : true
});
Cross-Platform Executable (requires @tsdown/exe) export default defineConfig ({
entry : ['src/cli.ts' ],
exe : {
targets : [
{ platform : 'linux' , arch : 'x64' , nodeVersion : '25.7.0' },
{ platform : 'darwin' , arch : 'arm64' , nodeVersion : '25.7.0' },
{ platform : 'win' , arch : 'x64' , nodeVersion : '25.7.0' }
]
}
});
Advanced with Hooks export default defineConfig ({
entry : ['src/index.ts' ],
format : ['esm' , 'cjs' ],
dts : true ,
hooks : {
'build:before' : async context => {
console .log ('Building...' );
},
'build:done' : async context => {
console .log ('Build complete!' );
}
}
});
Configuration Features
Multiple Configs Export an array for multiple build configurations:
export default defineConfig ([
{
entry : ['src/index.ts' ],
format : ['esm' , 'cjs' ],
dts : true
},
{
entry : ['src/cli.ts' ],
format : ['esm' ],
platform : 'node'
}
]);
Conditional Config Use functions for dynamic configuration:
export default defineConfig (options => {
const isDev = options.watch ;
return {
entry : ['src/index.ts' ],
format : ['esm' , 'cjs' ],
minify : !isDev,
sourcemap : isDev
};
});
Workspace/Monorepo Use glob patterns to build multiple packages:
export default defineConfig ({
workspace : 'packages/*' ,
entry : ['src/index.ts' ],
format : ['esm' , 'cjs' ],
dts : true
});
CLI Quick Reference
tsdown
tsdown --watch
tsdown --config custom.ts
npx tsdown-migrate
tsdown --format esm,cjs
tsdown -d lib
tsdown --minify
tsdown --dts
tsdown --exe
tsdown --unbundle
tsdown src/index.ts
tsdown src/*.ts
tsdown src/a.ts src/b.ts
tsdown -W
tsdown -W -F my-package
tsdown --filter /^pkg-/
tsdown --watch
tsdown --sourcemap
tsdown --clean
tsdown --from-vite
tsdown --tsconfig tsconfig.build.json
Best Practices
Always generate type declarations for TypeScript libraries:
{
dts : true ;
}
Externalize dependencies to avoid bundling unnecessary code:
{
deps : {
neverBundle : [/^react/ , /^@myorg\// ];
}
}
Use tree shaking for optimal bundle size:
{
treeshake : true ;
}
Enable minification for production builds:
{
minify : true ;
}
Add shims for better ESM/CJS compatibility:
{
shims : true ;
}
Auto-generate package.json exports :
{
exports : true ;
}
Use watch mode during development:
tsdown --watch
Preserve structure for utilities with many files:
{
unbundle : true ;
}
Validate packages in CI before publishing:
{ publint : 'ci-only' , attw : 'ci-only' }
Resources