Skip to main content
← Guides

Guide

tsup vs tsdown vs unbuild 2026

Updated PkgPulse Team9 min read
0

tsup, tsdown, and unbuild for TypeScript libraries: weigh maintenance, declarations, ESM/CJS output, stub mode, and migration checks before changing a working build.

Contents

As of November 1, 2026 (UTC), tsup's README says it is no longer actively maintained and refers readers to tsdown. An existing tsup library can keep a tested build while assessing migration costs. For a new library, evaluate maintenance, declarations and consumer formats before choosing tooling. Neither the notice nor a similar configuration establishes that tsdown is faster or compatible with your package; unbuild is another option to evaluate for its workflow.

Decisions for existing builds and new libraries

SituationDecision to evaluateDeclarationsOutput formatsCaveat to verify
Existing tsup library with working releasesKeep the current build while documenting maintenance responsibilityRetain and test the current dts setupPreserve existing ESM/CJS contracts and filenamesA maintenance notice alone does not prove a defect in your artifacts
Existing tsup library evaluating tsdownUse the migration guide on a branch and compare packed outputCheck declaration generation and consumer resolutionSet required formats explicitly; verify exported filenamesThe documented staged upgrade and removed options make a config rename insufficient
New library evaluating tsdownTest the required features before adopting itRequires TypeScript; declaration defaults depend on package metadataESM by default; CJS requires configurationA familiar option name is not a compatibility guarantee
New library considering unbuildEvaluate its Rollup-based packaging and local stub workflowConfigure declaration generation and inspect the filesConfigure CJS output if consumers require itDevelopment stubs do not replace a production build and packed-consumer tests

Sources checked November 1, 2026: tsup README, tsdown migration, declarations, formats and unbuild README. The decision table is an editorial framework. For direct bundler APIs and plugin control, see tsup vs Rollup vs esbuild.

Define the package contract before choosing a tool

A library build needs to satisfy the environments your consumers use. Decide whether you support ESM only or also CommonJS, which subpaths are public, and how TypeScript users resolve declarations. Dual output is useful when it serves those consumers; it is not mandatory for every new npm library.

Write down the current contract before testing replacements. Include runtime versions, root and subpath exports, peer dependencies, assets and any executable entry. A configuration that produces JavaScript successfully has established only part of that contract. Package metadata and the files included in the tarball matter just as much.

A TypeScript project also needs type checking. Transpilation removes types from runtime code; declaration generation describes the public API for consumers. Those are different jobs, and the tool responsible for one may not perform the other. Keep a separate type-checking check if the selected build workflow does not provide it.

For a new package, start with a small consumer fixture rather than adopting every output format in a template. For an existing package, use its published behavior as the baseline. Changing bundlers should not accidentally remove a subpath, bundle a peer dependency or change the shape of a default export without an intentional release decision.

tsup: maintaining a working library build

The tsup maintenance notice changes the planning question. Existing projects have a known configuration and release history, which can justify keeping a build while evaluating alternatives. New projects would be taking on that maintenance constraint from the outset. Popularity or familiarity alone is insufficient reason to make tsup the default for a new library.

The tsup configuration interface exposes entries, formats and declaration options. An existing configuration may look like this:

// tsup.config.ts — existing project example
import { defineConfig } from "tsup";

export default defineConfig({
  entry: {
    index: "src/index.ts",
    server: "src/server.ts",
  },
  format: ["esm", "cjs"],
  dts: true,
  splitting: false,
  sourcemap: true,
  clean: true,
  external: ["react"],
});

Keep the build command, lockfile and successful packed output as a baseline for comparison. If your current pipeline generates declarations separately, include that step too. Do not infer filenames only from this snippet: output naming depends on package metadata and configuration. Check what the build actually emits before using those paths in exports.

A decision to retain tsup should name who owns needed fixes and when to reassess. A concrete trigger might be an unsupported runtime, a plugin failure or a reproducible dependency issue. Review security advisories through their own evidence; the absence of active maintenance is not itself proof of a vulnerability in a published package.

This guide keeps tsup examples to explain existing builds. It does not recommend starting a new library with tsup on the assumption that its historical defaults remove future maintenance work.

tsdown: evaluate behavior, not a successor label

The tsup README points to tsdown, which uses Rolldown. Treat that referral as a candidate for evaluation. A different bundling engine and a similar configuration surface do not prove that a library's plugins, declarations or CommonJS behavior will remain equivalent.

The tsdown declaration documentation says declaration generation requires TypeScript and uses rolldown-plugin-dts. It can enable declarations from types, typings or a types entry in exports; you can also set dts: true. Its format documentation specifies ESM as the default. Set CJS explicitly when your support contract requires it.

// tsdown.config.ts — candidate to test, not a translated tsup config
import { defineConfig } from "tsdown";

export default defineConfig({
  entry: ["src/index.ts"],
  format: ["esm", "cjs"],
  dts: true,
  clean: true,
  sourcemap: true,
});

The format docs checked for this refresh describe CJS-specific features as maintenance-only. That is relevant if your package needs ongoing work on CommonJS interoperability. Evaluate the documented behavior against your consumers rather than assuming every format receives the same future investment.

Vite provides useful ecosystem context, but not a verdict for a standalone library. The Vite guide describes a Rolldown production build, and its Vite 8 migration documentation scopes the switch from Rollup and esbuild to Rolldown and Oxc to Vite 8. Those facts do not validate a tsup-to-tsdown migration or predict its timing.

Migrate from tsup with explicit verification

The tsdown migration guide, checked November 1, 2026, documents a migration utility with a preview mode:

npx tsdown-migrate --dry-run

Commit or back up your work before applying migration changes. The utility can modify configuration and install dependencies. Review its proposed changes before using it in a release branch.

The current instructions use a two-stage path: the utility installs v0.22.14, where deprecated tsup-compatible options still produce warnings. Resolve those warnings before upgrading to v0.23 or later. The docs say newer versions remove those options; they can fail type checking and be ignored at runtime. Follow the guide for the version you are installing instead of assuming a successful config load proves migration is complete.

After the configuration migration, validate the package itself:

  1. Build the old and candidate revisions from clean output directories. Compare files, public entries, externals, assets and source maps.
  2. Pack the candidate and install it into consumer fixtures. Source imports inside the monorepo can hide files missing from the tarball.
  3. Exercise ESM and CJS entry points where supported, including default exports, named exports and public subpaths.
  4. Compile TypeScript consumers against the packed declarations. Check the module-resolution modes you claim to support.
  5. Run the library's behavioral tests and inspect warnings. Record deliberate output changes before deciding how to release them.

These checks establish evidence for your package; the migration utility cannot establish it on your behalf. If a needed plugin or declaration case remains unresolved, keep the tested build while investigating. Preserve a straightforward rollback to the previous build rather than coupling the experiment to unrelated package changes.

unbuild: evaluate the build and stub workflows separately

The unbuild README describes a Rollup-based bundler with TypeScript declarations, package-metadata inference and a development stub mode. These are workflow features to test if they match your project. They are not evidence of greater adoption, faster builds or compatibility with another tool's configuration.

// build.config.ts
import { defineBuildConfig } from "unbuild";

export default defineBuildConfig({
  entries: ["src/index"],
  declaration: true,
  rollup: {
    emitCJS: true,
  },
  clean: true,
});

Use explicit entries while learning how the package metadata maps to source files. If you later rely on inference, make the resulting public entry list part of release validation. Test required Rollup integrations in unbuild's build workflow rather than assuming every standalone Rollup configuration transfers directly.

Stub mode supports a different local feedback loop:

# Local development stubs
npx unbuild --stub

# Production artifacts
npx unbuild

The README describes stubbing dist so a linked consumer can load source through jiti without watch rebuilds. This can be useful during development, but it exercises a different path from consuming a published bundle. A consumer that works with stubs may still fail after packing because of an exports error, missing asset or declaration mismatch.

Run a production build before packaging, and test the tarball independently of the stub workflow. If several packages in a monorepo consume one another, check that the release job replaces development stubs everywhere required. Keep that distinction visible in scripts and release instructions.

Declaration generation and package exports

ToolDeclaration responsibilityFormat responsibility
tsupExisting dts option or a separate declaration pipelinePreserve the project's configured formats and naming
tsdownTypeScript plus its declaration plugin; verify metadata-driven defaultsESM default; explicitly configure other required outputs
unbuildDeclaration configuration and emitted filesCheck inferred entries and configured CommonJS emission

Declarations deserve consumer tests even when generation is integrated. A file named index.d.ts is not proof that both ESM and CJS consumers resolve it correctly. Check the declaration paths attached to each export condition and subpath. If a generated declaration references a type from another dependency, confirm the consumer can resolve that dependency after installation.

Write the exports map from the files you intend to publish. For example, an import condition might target an .mjs file and a require condition a .cjs file; use the actual emitted paths. Do not copy an exports map from one tool's example while building with another tool's filename defaults.

Package validators can help identify metadata errors. publint vs arethetypeswrong vs pkg-pr-new covers complementary package checks. They supplement runtime and TypeScript fixtures; they do not establish that a change preserves every consumer's behavior.

Measure migration cost and build time locally

This guide does not report weekly download totals or speed multipliers. They would need a dated dataset or a reproducible benchmark, and neither would settle compatibility for your library. Measure the complete candidate workflow if build time is a reason to switch.

Use matching entries, formats, declaration settings, assets and source maps. Record the exact versions, machine and cache state. Compare a clean build with a repeat build, and separate dependency installation when investigating where time goes. A JavaScript-only timing cannot represent a release job that also produces declarations.

Include maintenance work in the decision. Count plugin replacements, declaration fixes, export changes and added consumer fixtures. A quicker compilation can still be an expensive migration if the published interface changes unexpectedly. Conversely, a migration may be justified by a required feature or maintainability even when timing barely changes.

For broader context, the tsup vs esbuild and Rollup comparison explains the responsibilities involved in owning a lower-level pipeline. Compare complete publishing workflows before narrowing the decision to the bundler engine.

Decide from the package you can verify

Retain an existing tsup build when it satisfies the current contract and the team accepts responsibility for needed maintenance. Evaluate a replacement when a concrete requirement or maintenance concern justifies the work. Keep the baseline and consumer fixtures available so the decision remains reversible.

For a new library, evaluate tooling against supported formats, declaration behavior, plugins and release checks. Test tsdown if its current feature set fits; test unbuild if its build and stub workflows fit. Neither earns a recommendation simply from a successor label or ecosystem association. The broader TypeScript-first build tools guide can help identify other candidates once the package requirements are clear.

Sources checked

Primary documentation accessed November 1, 2026 (UTC):