tsdown
tsdown handles the complexities of preparing TypeScript and JavaScript packages for npm distribution across multiple module formats. It automates bundling, format generation, and output optimization so you can focus on writing code rather than build configuration.
tsdown is a TypeScript library bundler designed to simplify npm package distribution. tsdown handles the complexities of preparing TypeScript and JavaScript packages for npm distribution across multiple module formats. It automates bundling, format generation, and output optimization so you can focus on writing code rather than build configuration. The tool is released under the MIT license and supports generating type declaration files while optimizing bundle size.
AI-generated summary based on this skill's SKILL.md
Install
sanity-io/next-sanity/tsdown · repository language: TypeScript
git clone https://github.com/sanity-io/next-sanity
cp -r next-sanity/.agents/skills/tsdown ~/.claude/skills/tsdownFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
What is tsdown and what does it do for TypeScript library bundling?
tsdown is a TypeScript library bundler designed to simplify npm package distribution. tsdown handles the complexities of preparing TypeScript and JavaScript packages for npm distribution across multiple module formats. It automates bundling, format generation, and output optimization so you can focus on writing code rather than build configuration. The tool is released under the MIT license and supports generating type declaration files while optimizing bundle size.
Can tsdown bundle TypeScript declarations and generate multiple output formats?
Yes, tsdown excels at this core function. tsdown generates type declaration files and optimizes bundle size as a primary capability. It bundles TypeScript and JavaScript libraries for npm with multiple output formats, allowing you to produce ESM, CJS, and other module formats from a single configuration. This eliminates the need to manually manage separate build pipelines for different output targets.
How does tsdown compare to tsup, and can I migrate from tsup to tsdown?
tsdown is positioned as a faster alternative to tsup with minimal configuration changes required. One of tsdown's key strengths is enabling migration from tsup to a faster bundler while maintaining compatibility with your existing setup. If you're currently using tsup and looking for improved build performance, tsdown offers a streamlined path forward without requiring a complete rebuild of your configuration.
Does tsdown support building component libraries for React, Vue, Solid, or Svelte?
Yes, tsdown supports building React, Vue, Solid, or Svelte component libraries as a dedicated use case. This makes tsdown suitable for teams developing framework-specific component packages that need to be distributed across multiple module formats while maintaining proper type definitions and optimized bundle sizes.
Can tsdown be used for workspace and monorepo builds with CI-aware settings?
tsdown includes support for configuring workspace and monorepo builds with CI-aware settings. This capability allows you to manage multiple interdependent packages within a single repository while automatically adapting build behavior based on your continuous integration environment, making it well-suited for complex project structures.
What features does tsdown provide for optimizing and monitoring TypeScript bundle output?
tsdown provides comprehensive optimization features including minification, tree shaking, and source map generation for TypeScript bundles. The bundler focuses on reducing output size while maintaining code quality and debuggability. Additionally, tsdown offers watch mode for development workflows, allowing you to iterate quickly while building libraries with proper type declarations and multiple output formats.
SKILL.md
rendered from the published skill — quoted content, verbatim
tsdown - The Elegant Library Bundler
Blazing-fast bundler for TypeScript/JavaScript libraries powered by Rolldown and Oxc.
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
# Install
pnpm add -D tsdown
# Basic usage
npx tsdown
# With config file
npx tsdown --config tsdown.config.ts
# Watch mode
npx tsdown --watch
# Migrate from tsup
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
| Topic | Description |
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 15 files
.agents/skills/tsdown/LICENSE.md
.agents/skills/tsdown/README.md
.agents/skills/tsdown/SKILL.md
.agents/skills/tsdown/SYNC.md
.agents/skills/tsdown/references/README.md
.agents/skills/tsdown/references/advanced-benchmark.md
.agents/skills/tsdown/references/advanced-ci.md
.agents/skills/tsdown/references/advanced-hooks.md
.agents/skills/tsdown/references/advanced-plugins.md
.agents/skills/tsdown/references/advanced-programmatic.md
.agents/skills/tsdown/references/advanced-rolldown-options.md
.agents/skills/tsdown/references/guide-getting-started.md
.agents/skills/tsdown/references/guide-introduction.md
.agents/skills/tsdown/references/guide-migrate-from-tsup.md
.agents/skills/tsdown/references/option-cjs-default.md