Guide · Open source
How to use tsup: bundle a TypeScript library with no config
Updated · written with AI from the project's own documentation and checked against our catalogue data
tsup is a command-line bundler for TypeScript and JavaScript libraries. It uses esbuild under the hood and aims to need little or no build configuration. This guide shows how to install it, run it on your source files, and what to check before you adopt it, including the project's notice that it is no longer actively maintained.
Quick start
- 1Confirm tsup fits your project. Read the README warning and decide whether your project is an existing tsup user. If it is a new project, consider tsdown instead.
- 2Install tsup locally. Run npm i tsup -D, yarn add tsup --dev or pnpm add tsup -D in your project folder.
- 3Choose your entry files. Pick the TypeScript or JavaScript files you want to bundle, such as src/index.ts.
- 4Run tsup on the files. Run tsup followed by your file paths, for example tsup src/index.ts src/cli.ts.
- 5Check the dist folder. Open ./dist to find the generated output files, such as dist/index.js.
Check whether tsup is the right choice
Before installing, read the project's warning. The README says tsup is no longer actively maintained and recommends tsdown instead, with a migration guide linked from the README.
tsup is best suited to people who maintain a TypeScript library, want a simple build step, and already use tsup in an existing project that does not need new features. For a new project, the README's recommendation points to tsdown.
- New projects: consider tsdown, as the README suggests.
- Existing tsup projects that work as they are: no new features or ongoing bug fixes should be expected.
- CSS bundling: the README labels it experimental, so do not rely on it as a stable feature.
Install tsup in your project
The README recommends installing tsup locally in your project folder, as a development dependency. You need Node.js and one of npm, yarn or pnpm. Pick the command for your package manager.
The README says you can also install it globally but that this is not recommended.
npm i tsup -D
# Or Yarn
yarn add tsup --dev
# Or pnpm
pnpm add tsup -DBundle your files with tsup
Run tsup followed by the files you want to bundle. According to the README, files are written into ./dist. You can pass several entry files in one command.
For example, passing src/index.ts and src/cli.ts outputs dist/index.js and dist/cli.js.
- Output goes to ./dist by default, as stated in the README.
- Each input file produces its own output file in dist.
tsup [...files]
tsup src/index.ts src/cli.tsKnow which file types tsup accepts
The README says tsup can bundle anything Node.js supports natively: .js, .json and .mjs files, plus TypeScript .ts and .tsx files. CSS support is listed as experimental and links to a CSS section in the docs.
For configuration options beyond the basic command, the README points to the tsup documentation site and to the API docs on jsdocs.io. This guide does not cover those options in detail.
- .js, .json, .mjs, .ts and .tsx are the file types named in the README.
- CSS is experimental.
Find more details in the docs
The README sends readers to the tsup documentation at tsup.egoist.dev for complete usage. Discussions for sharing ideas are on the project's GitHub discussions page.
Because the project is no longer actively maintained, check the README's current notice before you depend on any documented behaviour.
What people use it for
- Bundling a TypeScript library into JavaScript files ready to publish, as the project describes its purpose.
- Building a library entry point and a CLI entry point in one command, for example src/index.ts and src/cli.ts.
- Maintaining an existing library that already uses tsup and does not need new features.
Frequently asked questions
How do I install tsup?
Install it locally in your project folder with npm i tsup -D, yarn add tsup --dev, or pnpm add tsup -D. The README says a global install is possible but not recommended.
Is tsup free to use?
tsup is released under the MIT licence, as shown in the README. The licence text credits EGOIST.
Is tsup still maintained?
No. The README warns that the project is not actively maintained anymore and suggests tsdown instead, with a migration guide.
What file types can tsup bundle?
The README says tsup handles .js, .json, .mjs, .ts and .tsx files. CSS support is experimental.
Where does tsup write its output?
According to the README, files are written into ./dist. Bundling src/index.ts and src/cli.ts outputs dist/index.js and dist/cli.js.
What are the alternatives to tsup?
The comparable projects listed for this item are tsdown, esbuild and Rollup. The README specifically recommends tsdown as the successor.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
tsup suits developers who already maintain a TypeScript library on tsup and want to keep a simple build step without a complex configuration. Because the README says it is no longer actively maintained, new projects should pick tsdown, which the README recommends, and anyone needing CSS bundling as a stable feature should look elsewhere.
Install options & downloads