chore(repo): Update rolldown and tsdown#8207
chore(repo): Update rolldown and tsdown#8207dstaley wants to merge 4 commits intods.chore/ts-6.0from
Conversation
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| "require": { | ||
| "types": "./dist/index.d.ts", | ||
| "default": "./dist/index.js" | ||
| "types": "./dist/index.d.cts", |
There was a problem hiding this comment.
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.
packages/react/tsdown.config.mts
Outdated
| minify: false, | ||
| sourcemap: true, | ||
| external: ['react', 'react-dom'], | ||
| external: ['react', 'react-dom', '@clerk/ui/internal'], |
There was a problem hiding this comment.
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?
Description
Update tsdown and rolldown to their latest versions. This surfaced several issues with our type system, which have been resolved in this PR:
@clerk/shared, usingtscinstead of bundling types withtsdown. This prevents issues where the same type was pulled fromdist/typesanddist/runtime.tsc, the@/path alias was removed in favor of relative imports. We can explore using"imports"inpackage.jsonin a future PR if we know that every runtime@clerk/sharedsupports has support for that.@clerk/reactby 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)Uitype in the@clerk/reactpackage that allows the bundledUitype and the one used by the@clerk/uipackage to match, preventing TypeScript from complaining that the types don't match.turbo.jsonto factor intsdown.config.mtsinto whether or not to invalidate the cache.Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change