-
Notifications
You must be signed in to change notification settings - Fork 267
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
chore(nextjs): Introduce build-time error for server-only helpers on client-side #3758
Conversation
🦋 Changeset detectedLatest commit: e8048e9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
1fa5832
to
790eea2
Compare
@@ -1,3 +1,5 @@ | |||
jest.mock('server-only', () => null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's tricky to run server-only
on Jest due to its multiple environments. I went ahead and decided to mock it instead:
@@ -1,3 +1,5 @@ | |||
import 'server-only'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've imported it separately on auth
and currentUser
only instead of importing it once on server
index.
My concern is that the error would be thrown even when importing type definitions, but I'd like to minimize the surface here.
Description
Resolves #3660
Uses the
server-only
package to throw a build-time error if Clerk server-side helpers get accidentally imported on the client side.Checklist
npm test
runs as expected.npm run build
runs as expected.Type of change