chore(*): Improve @clerk/backend DX [Part 2 - Errors subpath exports]#2362
Conversation
🦋 Changeset detectedLatest commit: 637d245 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
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 |
d941960 to
88fab3a
Compare
e5e6a46 to
b1bf17b
Compare
nikosdouvlis
left a comment
There was a problem hiding this comment.
Great job @dimkl , 2 minor comments but apart from that, good to go
| }, | ||
| "./package.json": "./package.json" | ||
| }, | ||
| "main": "./dist/index.js", |
There was a problem hiding this comment.
Let's drop main but keep types since TS configs with moduleResolution set to node will not be able to resolve the types otherwise.
TS will use the exports field only if moduleResolution is set to node16, nodenext or bundler. Many projects still use node though, so let's not be disruptive.
Extra context: https://www.typescriptlang.org/tsconfig#moduleResolution
| export function createClerkClient(options: ClerkOptions) { | ||
| // The current exported type resolves the following issue in packages importing createClerkClient | ||
| // TS4023: Exported variable 'clerkClient' has or is using name 'AuthErrorReason' from external module "/packages/backend/dist/index" but cannot be named. | ||
| export type ClerkClient = { |
There was a problem hiding this comment.
Discussed offline, problematic area with types and type inference, will come back to this after v5 or next week.
98dae0d to
3eb7f72
Compare
…s for both esm and cjs This change resolves issues with inferred types. Eg: ``` The inferred type of 'auth' cannot be named without a reference to ... ```
Removing those, resolves some issues with our type resolution
and also makes our exposed API cleaner.
```
// Before
import { users } from "@clerk/clerk-sdk-node"
// After
import { clerkClient } from "@clerk/clerk-sdk-node"
clerkClient.users
Co-authored-by: Nikos Douvlis <nikosdouvlis@gmail.com>
2776f31 to
802b762
Compare
The attw was failing in attw due to ``` 🎭 Masquerading as CJS ```
fc3c68e to
75b6bee
Compare
06c64d6 to
637d245
Compare
Description
Introduce
/errorssubpath in@clerk/backendand perform some cleanups and changes to@clerk/clerk-sdk-nodeto fix some issues caused by the resolution of the types with the subpath exports.Review it per commit.
Checklist
npm testruns as expected.npm run buildruns as expected.Type of change
Packages affected
@clerk/backend@clerk/chrome-extension@clerk/clerk-js@clerk/clerk-expo@clerk/fastifygatsby-plugin-clerk@clerk/localizations@clerk/nextjs@clerk/clerk-react@clerk/remix@clerk/clerk-sdk-node@clerk/shared@clerk/themes@clerk/typesbuild/tooling/chore