gitmyhub

tsup

TypeScript ★ 11k updated 7d ago

The simplest and fastest way to bundle your TypeScript libraries.

A zero-config command-line tool for bundling TypeScript libraries into JavaScript, powered by esbuild for fast builds, though the author now recommends the successor tool tsdown.

TypeScriptesbuildNode.jssetup: easycomplexity 2/5

tsup is a command-line tool for bundling TypeScript libraries into distributable JavaScript files. It is designed to require no configuration for typical use cases, making it quick to set up compared to tools that need extensive configuration files before they will run.

The tool is powered by esbuild, a JavaScript bundler known for fast build times. You point tsup at one or more TypeScript source files and it outputs compiled JavaScript files into a dist folder. It supports common file types that Node.js handles natively, including .js, .mjs, and .json, along with .ts and .tsx TypeScript files. CSS bundling is noted as experimental.

Installing tsup is done via npm, yarn, or pnpm as a development dependency in your project. Once installed, you can run it directly from the command line or add it to the scripts section of your package.json. No separate configuration file is required for common scenarios, though configuration options are available for more specific setups.

Basic usage is a single command: tsup src/index.ts. Multiple entry files can be provided at once, and each produces a corresponding output file in the dist directory. Full configuration options and documentation are available on the project website.

The README includes a prominent warning: the project is no longer actively maintained. The author recommends switching to a tool called tsdown instead, and a migration guide is linked. This is worth noting if you are evaluating tsup for a new project. The project is MIT-licensed and accumulated over 11,000 GitHub stars during its active period.

Where it fits