tsup
tsup is a zero-config TypeScript bundler powered by esbuild, designed specifically for building TypeScript libraries and packages with minimal setup. tsup produ…
Installation
npm install -D tsup
yarn add -D tsup
pnpm add -D tsup
Import
// tsup.config.ts
import { defineConfig } from 'tsup';Quick Example
// tsup.config.ts
import { defineConfig } from 'tsup';
export default defineConfig({
entry: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
splitting: true,
clean: true,
});About tsup
tsup is a zero-config TypeScript bundler powered by esbuild, designed specifically for building TypeScript libraries and packages with minimal setup. tsup produces both ESM and CommonJS outputs from the same source, generates TypeScript declaration files (.d.ts), and handles CSS bundling — all with sensible defaults that can be overridden through a tsup.config.ts file or command-line flags. The tool significantly simplifies the library publishing workflow by handling the common requirement of shipping dual CJS/ESM packages with proper TypeScript types. tsup supports tree shaking, code splitting, source maps, watch mode for development, environment variable injection, and custom esbuild plugins. The declaration file generation uses TypeScript's compiler API rather than esbuild, ensuring accurate type output. tsup automatically externalizes dependencies listed in package.json's dependencies and peerDependencies fields, keeping the bundle lean. For library authors, tsup replaces a complex chain of tools (TypeScript compiler + Rollup/esbuild + plugins) with a single command. tsup has become the most popular choice for building TypeScript packages due to its speed, simplicity, and sensible defaults.
Quick Facts
| Package | tsup |
| Category | Build Tool |
| Weekly Downloads | 2M+ |
| License | MIT |
| Install | npm install -D tsup |
Related Packages
esbuild is an extremely fast JavaScript and TypeScript bundler and minifier written in Go that is 10…
Rollup is a JavaScript module bundler that compiles small pieces of code into larger, more complex b…
unbuild is a unified JavaScript build system created by the UnJS team that provides a preset-based, …
Microbundle is a zero-configuration bundler for tiny JavaScript modules, designed to produce optimiz…
TypeScript is a strongly typed programming language that builds on JavaScript, adding static type de…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.