🔧
Build Tool2M+/wkMIT

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
npm install -D tsup
yarn
yarn add -D tsup
pnpm
pnpm add -D tsup

Import

ESM
// tsup.config.ts
import { defineConfig } from 'tsup';

Quick Example

usage
// 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

Packagetsup
CategoryBuild Tool
Weekly Downloads2M+
LicenseMIT
Installnpm install -D tsup

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.