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

Migrating a Real TypeScript OSS Library from tsup to tsdown

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

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

Задача

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

Результат

The migration required only configuration changes and a smoke test. The package contract was preserved by customizing outExtensions, and the final artifact met all original export and declaration expectations. Build time was similar, and the output size increased by ~23.6%.

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

  • Replace tsup with tsdown dependency
  • 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 differ
  • Add outExtensions function to map format to desired extensions
  • Run pnpm build again – filenames match original contract
  • Run packed‑package smoke test to verify exports, runtime, and declarations
  • Measure artifact size and build time for comparison

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

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-22T21:26:11.924Z