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 succeeded after adjusting outExtensions to keep the original file names, ensuring consumers see the same package contract.
Рабочий процесс
- Replace tsup with tsdown and create tsdown.config.mts
- Map tsup options to tsdown (entry, format, dts, clean, outDir, target, banner)
- Run pnpm build – build succeeds but filenames differ
- Identify mismatch between generated files and package.json exports
- Add outExtensions mapping to preserve original filenames
- Rebuild – filenames now match exports
- Run packed‑package smoke test to verify consumer behavior
Доказательства
The first tsdown build succeeded while silently changing files that were already part of the package's public contract.
Build success ≠ package contract preserved.
I used outExtensions to preserve the existing filenames
- Дата записи: 2026-10-07T16:55:55.465Z