Skip to content

Migrate build from tsup to tsdown (Rolldown) #1369

Description

@jbetancur

Summary

Evaluate migrating the library build from tsup to tsdown (the Rolldown-based successor).

Motivation

tsup maintenance has slowed — latest publish was ~8 months ago (v8.5.1, 2025-11-12) — while tsdown is actively developed and is the direction the esbuild/Rolldown tooling ecosystem is consolidating toward. Rolldown also generally produces faster builds and better-optimized output. This is about staying on maintained tooling, not a bug in the current build.

Current build surface (what a migration must preserve)

tsup.config.ts has three build passes and leans on a few tsup-specific behaviors that need to be re-verified under tsdown:

  • Dual format: esm + cjs, with dts: true, sourcemaps, minify, treeshake, external: ['react','react-dom'].
  • injectStyle: true on the main bundle (CSS injected at runtime so most consumers need no CSS import). tsdown's CSS handling differs — this is the highest-risk item.
  • CSS-only pass: a third build that emits dist/DataTable.css for SSR consumers (Next.js App Router), then deletes the duplicate JS via an onSuccess rm. Needs an equivalent.
  • "use client" banner: added post-build via scripts/use-client-banner.mjs because tsup strips a configured banner during treeshake. Confirm whether tsdown preserves a top-of-file directive natively (may let us drop the script).
  • Locales sub-bundle: ./locales entry, and the ./css export.

Acceptance criteria

  • dist/ output is byte-compatible in structure: index.js/index.mjs/index.d.ts, locales/, DataTable.css, sourcemaps.
  • All three exports map entries (., ./locales, ./css) resolve identically.
  • "use client" is present at the top of both index.js and index.mjs.
  • Runtime CSS injection still works for the default import path; the explicit ./css import still works for SSR.
  • npm run build + the existing test/lint/typecheck all pass; smoke-test in a Next.js App Router app (Server Component import) and a plain Vite app.

Notes

Keep it behind a branch and diff the dist/ output against the tsup build before switching. If any of the CSS-injection or use client behaviors regress and can't be reproduced cleanly, hold — the current build works, so this is opportunistic, not urgent.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions