What is tsup?

tsup is a super-fast JavaScript/TypeScript bundler built on esbuild. It’s designed for libraries: minimal config, great defaults, and it can spit out ESM + CJS builds (and type declarations) in one go.

Why people use tsup

🚀 Speed (esbuild …


This content originally appeared on DEV Community and was authored by teaganga

tsup is a super-fast JavaScript/TypeScript bundler built on esbuild. It’s designed for libraries: minimal config, great defaults, and it can spit out ESM + CJS builds (and type declarations) in one go.

Why people use tsup

  • 🚀 Speed (esbuild under the hood)
  • 🧩 Zero/low config (works from the CLI or a tiny config file)
  • 📦 Dual output (esm + cjs) for broad compatibility
  • 📝 Type defs: can emit .d.ts with dts: true
  • 🔧 Nice extras: watch mode, minify, treeshake, code splitting, sourcemaps

Quick start

npm i -D tsup typescript

package.json

{
  "scripts": {
    "build": "tsup",
    "dev": "tsup --watch",
    "prepare": "npm run build"
  }
}

tsup.config.ts

import { defineConfig } from 'tsup';

export default defineConfig({
  entry: ['src/index.ts'],
  format: ['esm', 'cjs'],
  dts: true,        // emit .d.ts
  sourcemap: true,
  clean: true,
  target: 'es2020',
  treeshake: true
});

tsconfig.json (minimal)

{
  "compilerOptions": {
    "target": "ES2020",
    "moduleResolution": "bundler",
    "strict": true,
    "declaration": true,
    "emitDeclarationOnly": false,
    "skipLibCheck": true
  },
  "include": ["src"]
}

Run:

npm run build

You’ll get dist/index.mjs, dist/index.cjs, and dist/index.d.ts.

How it compares

  • tsc: compiles TS → JS, but doesn’t bundle (each file out). tsup bundles your code (and can mark deps as external).
  • rollup/webpack: very flexible; more config. tsup is “rollup-lite” for libs—fast and simple.
  • vite: great for apps/dev servers; you can build libs, but tsup is often simpler for publishing packages.

When to use / not use

  • Use tsup for publishing libraries quickly with dual builds + types.
  • If you need exotic bundling (custom plugins, unusual module targets), rollup/webpack may still be better.
  • If you want no bundling at all, just tsc might suffice.

Conclusion

That’s it—tsup = fast, simple library bundling with type definitions baked in.


This content originally appeared on DEV Community and was authored by teaganga


Print Share Comment Cite Upload Translate Updates
APA

teaganga | Sciencx (2025-08-30T15:21:34+00:00) What is tsup?. Retrieved from https://www.scien.cx/2025/08/30/what-is-tsup/

MLA
" » What is tsup?." teaganga | Sciencx - Saturday August 30, 2025, https://www.scien.cx/2025/08/30/what-is-tsup/
HARVARD
teaganga | Sciencx Saturday August 30, 2025 » What is tsup?., viewed ,<https://www.scien.cx/2025/08/30/what-is-tsup/>
VANCOUVER
teaganga | Sciencx - » What is tsup?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/08/30/what-is-tsup/
CHICAGO
" » What is tsup?." teaganga | Sciencx - Accessed . https://www.scien.cx/2025/08/30/what-is-tsup/
IEEE
" » What is tsup?." teaganga | Sciencx [Online]. Available: https://www.scien.cx/2025/08/30/what-is-tsup/. [Accessed: ]
rf:citation
» What is tsup? | teaganga | Sciencx | https://www.scien.cx/2025/08/30/what-is-tsup/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.