Skip to content

[spike] Try out tsdown #5872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from

Conversation

LekoArts
Copy link
Member

@LekoArts LekoArts commented May 7, 2025

Description

After trying out https://tsdown.dev/ in a couple of OSS projects of mine I was curious what it would take to migrate our usage of tsup to it here.

In my personal testing I saw that with isolatedDeclarations you run into problems like microsoft/TypeScript#58944 where complex computed types (e.g. through Zod) would need to be written out. In general, enabling this option would effectively force us to enable https://typescript-eslint.io/rules/explicit-function-return-type/. Not necessarily a bad thing to do, but something we have to decide on.

tsdown is I think nearly on par with tsup in terms of what we need from it (except for the edge cases). I was excited to read in https://tsdown.dev/guide/dts that also declaration map generation is available. We need those for Typedoc generation.

Here's a speed comparison on my personal MacBook:

tsup

➜ hyperfine 'pnpm build && pnpm build:declarations'
Benchmark 1: pnpm build && pnpm build:declarations
  Time (mean ± σ):      2.247 s ±  0.048 s    [User: 4.370 s, System: 0.265 s]
  Range (min … max):    2.184 s …  2.348 s    10 runs

tsdown

➜ hyperfine 'pnpm build'
Benchmark 1: pnpm build
  Time (mean ± σ):     778.6 ms ±  26.9 ms    [User: 1268.8 ms, System: 160.9 ms]
  Range (min … max):   745.8 ms … 822.1 ms    10 runs

As you can see, much faster! The types package is a good candidate for the isolatedDeclarations option but even without it tsdown should generally be faster. Especially if we need to generate declarations for it, too.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Copy link

changeset-bot bot commented May 7, 2025

🦋 Changeset detected

Latest commit: 0e34026

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented May 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 7, 2025 0:55am

@LekoArts LekoArts closed this May 7, 2025
@LekoArts LekoArts deleted the lekoarts/eco-638-spike-tsdown-for-js-monorepo branch May 7, 2025 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants