Skip to content

chore(repo): Update rolldown and tsdown#8207

Open
dstaley wants to merge 4 commits intods.chore/ts-6.0from
ds.chore/ts-6.0-rolldown-update
Open

chore(repo): Update rolldown and tsdown#8207
dstaley wants to merge 4 commits intods.chore/ts-6.0from
ds.chore/ts-6.0-rolldown-update

Conversation

@dstaley
Copy link
Copy Markdown
Member

@dstaley dstaley commented Mar 31, 2026

Description

Update tsdown and rolldown to their latest versions. This surfaced several issues with our type system, which have been resolved in this PR:

  1. We're now only building one type tree for @clerk/shared, using tsc instead of bundling types with tsdown. This prevents issues where the same type was pulled from dist/types and dist/runtime.
  2. To support emitting types with tsc, the @/ path alias was removed in favor of relative imports. We can explore using "imports" in package.json in a future PR if we know that every runtime @clerk/shared supports has support for that.
  3. Fixed an issue with CJS type resolution in @clerk/react by pointing the "require" "types" field to the emitted CJS type bundle (which has been updated to simply re-export the exports of the ESM version)
  4. Created a structurally-similar Ui type in the @clerk/react package that allows the bundled Ui type and the one used by the @clerk/ui package to match, preventing TypeScript from complaining that the types don't match.
  5. Updates turbo.json to factor in tsdown.config.mts into whether or not to invalidate the cache.

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:

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 31, 2026

⚠️ No Changeset found

Latest commit: b4057e4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

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

Click here to learn what changesets are, and how to add one.

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

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Error Error Apr 2, 2026 5:24pm

Request Review

"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
"types": "./dist/index.d.cts",
Copy link
Copy Markdown
Member Author

@dstaley dstaley Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think it's somewhat strange that tsdown emits both mts and cts files. I would have thought that the CJS files would be js since the package doesn't have "type": "module". After looking into the config for tsdown it does appear that this is to be expected though. When you emit a cjs bundle, tsdown defaults platform to "node", which forces the fixedExtensions config to be true. So it does seem like this is intentional for dual ESM+CJS packages.

minify: false,
sourcemap: true,
external: ['react', 'react-dom'],
external: ['react', 'react-dom', '@clerk/ui/internal'],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I built @clerk/react with this branch and checked the output. dist/index.d.mts has import { Theme, Ui } from "@clerk/ui/internal" and the global ClerkAppearanceRegistry augmentation right below it. dist/internal.d.mts has the same for Ui.

Since @clerk/ui is a devDep of @clerk/react, consumers wont have it in their tree. The global augmentation gets pulled in as a side effect (import './types/appearance' in index.ts), so any import from @clerk/react needs @clerk/ui resolvable for type checking. Same for framework SDKs since they all import Ui from @clerk/react/internal.

Making @clerk/ui a full dep isnt viable given its dep tree (emotion, floating-ui, solana, etc). Not sure whats the best path here - maybe keeping it not-external and finding a different fix for the unique symbol duplication?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants