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 configuration but required explicit filename mapping to preserve the package contract. The smoke test confirmed that consumers would receive the same API and declarations. Artifact size increased by ~23.6% and build time improved marginally, but the primary benefit was maintaining compatibility.

工作流

  • 1. Replace tsup dependency with tsdown.
  • 2. Rename tsup.config.ts to tsdown.config.mts and adjust options (entry, format, dts, clean, outDir, target, banner).
  • 3. Run pnpm build – observe that output filenames differ from package.json exports.
  • 4. Add outExtensions to map cjs outputs to .js and dts outputs to .d.ts, preserving original filenames.
  • 5. Run the existing packed‑package smoke test to verify exports, runtime, and declarations.
  • 6. 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 added outExtensions to preserve the existing filenames

来源

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

来源

  • 记录日期: 2026-11-02T16:29:04.711Z