Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Migrating a Real TypeScript OSS Library from tsup to tsdown

Описание и применение

Перенос библиотеки is‑kit из tsup в tsdown потребовал сохранения имен файлов, чтобы не нарушить контракт пакета. После настройки outExtensions и проверки через тест пакета, контракт остался неизменным, хотя размер артефакта вырос.

Задача

Preserve the published package contract while switching the build tool from tsup to tsdown.

Результат

The migration was straightforward in terms of code changes but required careful handling of output filenames to keep the package contract intact. A smoke test that installs the packed tarball verified that consumers still received the same API and types.

Рабочий процесс

  • Replace tsup dependency with tsdown
  • Rename tsup.config.ts to tsdown.config.mts
  • Copy most config options (entry, format, dts, clean, outDir, target, banner)
  • Run pnpm build
  • Observe that output filenames changed
  • Add outExtensions to map cjs to .js and dts to .d.ts
  • Run pnpm build again
  • Run packed‑package smoke test to verify exports, types, runtime, and declaration banner

Доказательства

The first tsdown build succeeded while silently changing files that were already part of the package's public contract.

Источник

The config migration was small. Preserving the package contract was the interesting part.

Источник

I used outExtensions: ({ format }) => ({ dts: format === 'cjs' ? '.d.ts' : '.d.mts', js: format === 'cjs' ? '.js' : '.mjs', }),

Источник

After the migration, I expanded the test to verify more of the package contract

Источник

The tsdown output retained more comments and region markers than the previous tsup output.

Источник

  • Дата записи: 2026-10-15T18:41:13.881Z