Skip to content

chore(*): Improve @clerk/backend DX [Part 2 - Errors subpath exports]#2362

Merged
dimkl merged 8 commits into
mainfrom
sdk-974-improve-dx-backend-p2-errors
Dec 15, 2023
Merged

chore(*): Improve @clerk/backend DX [Part 2 - Errors subpath exports]#2362
dimkl merged 8 commits into
mainfrom
sdk-974-improve-dx-backend-p2-errors

Conversation

@dimkl

@dimkl dimkl commented Dec 14, 2023

Copy link
Copy Markdown
Contributor

Description

Introduce /errors subpath in @clerk/backend and perform some cleanups and changes to @clerk/clerk-sdk-node to fix some issues caused by the resolution of the types with the subpath exports.

Review it per commit.

Checklist

  • npm test runs as expected.
  • npm run 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:

Packages affected

  • @clerk/backend
  • @clerk/chrome-extension
  • @clerk/clerk-js
  • @clerk/clerk-expo
  • @clerk/fastify
  • gatsby-plugin-clerk
  • @clerk/localizations
  • @clerk/nextjs
  • @clerk/clerk-react
  • @clerk/remix
  • @clerk/clerk-sdk-node
  • @clerk/shared
  • @clerk/themes
  • @clerk/types
  • build/tooling/chore

@dimkl dimkl requested a review from nikosdouvlis December 14, 2023 22:19
@dimkl dimkl self-assigned this Dec 14, 2023
@changeset-bot

changeset-bot Bot commented Dec 14, 2023

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 637d245

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

This PR includes changesets to release 6 packages
Name Type
@clerk/clerk-sdk-node Major
@clerk/backend Major
@clerk/nextjs Major
gatsby-plugin-clerk Patch
@clerk/fastify Patch
@clerk/remix Patch

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

@dimkl dimkl changed the title chore(*): Improve @clerk/backend DX [Part 1 - Errors subpath exports] chore(*): Improve @clerk/backend DX [Part 2 - Errors subpath exports] Dec 14, 2023
@dimkl dimkl mentioned this pull request Dec 14, 2023
24 tasks
@dimkl dimkl force-pushed the sdk-974-improve-dx-backend-p1-refactors branch from d941960 to 88fab3a Compare December 14, 2023 23:56
@dimkl dimkl force-pushed the sdk-974-improve-dx-backend-p2-errors branch from e5e6a46 to b1bf17b Compare December 14, 2023 23:58

@nikosdouvlis nikosdouvlis left a comment

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.

Great job @dimkl , 2 minor comments but apart from that, good to go

Comment thread .changeset/fifty-snakes-accept.md Outdated
Comment thread .changeset/tasty-terms-fly.md
},
"./package.json": "./package.json"
},
"main": "./dist/index.js",

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.

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

@dimkl dimkl Dec 15, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i will apply it as part of: #2365

Comment thread packages/sdk-node/src/index.ts
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 = {

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.

Discussed offline, problematic area with types and type inference, will come back to this after v5 or next week.

@dimkl dimkl force-pushed the sdk-974-improve-dx-backend-p1-refactors branch 2 times, most recently from 98dae0d to 3eb7f72 Compare December 15, 2023 10:16
Base automatically changed from sdk-974-improve-dx-backend-p1-refactors to main December 15, 2023 10:39
dimkl and others added 6 commits December 15, 2023 12:48
…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>
@dimkl dimkl force-pushed the sdk-974-improve-dx-backend-p2-errors branch from 2776f31 to 802b762 Compare December 15, 2023 10:50
@dimkl dimkl enabled auto-merge December 15, 2023 11:03
The attw was failing in attw due to
```
 🎭 Masquerading as CJS
```
@dimkl dimkl force-pushed the sdk-974-improve-dx-backend-p2-errors branch from fc3c68e to 75b6bee Compare December 15, 2023 11:06
@dimkl dimkl force-pushed the sdk-974-improve-dx-backend-p2-errors branch from 06c64d6 to 637d245 Compare December 15, 2023 11:45
@dimkl dimkl added this pull request to the merge queue Dec 15, 2023
Merged via the queue into main with commit 9b02c1a Dec 15, 2023
@dimkl dimkl deleted the sdk-974-improve-dx-backend-p2-errors branch December 15, 2023 11:57
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.

3 participants