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