Skip to content
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

fix(nextjs): Ensure package works with next 12 #2652

Merged
merged 2 commits into from
Jan 23, 2024

Conversation

BRKalow
Copy link
Member

@BRKalow BRKalow commented Jan 22, 2024

Description

Adjust how we import next/navigation in the auth() helper to ensure our package can be safely imported in Next.js v12. The current recommended approach to use webpack.IgnorePlugin doesn't when the package is externally required in a CJS environment.

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

@BRKalow BRKalow requested a review from a team as a code owner January 22, 2024 19:46
@BRKalow BRKalow requested review from tmilewski and removed request for a team January 22, 2024 19:46
Copy link

changeset-bot bot commented Jan 22, 2024

🦋 Changeset detected

Latest commit: 91703d8

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

This PR includes changesets to release 1 package
Name Type
@clerk/nextjs 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

Comment on lines +54 to +55
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { notFound, redirect } = require('next/navigation');
Copy link
Member Author

Choose a reason for hiding this comment

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

auth() should never be used in v12, but due to the module structure of the package and the unconditional import of next/navigation, in a CJS environment node was trying to resolve the next/navigation import. Shifting this inline fixes it.

@BRKalow
Copy link
Member Author

BRKalow commented Jan 22, 2024

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @BRKalow - the snapshot version command generated the following package versions:

Package Version
@clerk/nextjs 4.29.5-snapshot.v91703d8

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/nextjs

npm i @clerk/nextjs@4.29.5-snapshot.v91703d8 --save-exact

@BRKalow BRKalow changed the title fix(nextjs): Ensure packages work with next 12 fix(nextjs): Ensure package works with next 12 Jan 22, 2024
@nikosdouvlis nikosdouvlis added this pull request to the merge queue Jan 23, 2024
@nikosdouvlis nikosdouvlis removed this pull request from the merge queue due to a manual request Jan 23, 2024
@nikosdouvlis nikosdouvlis merged commit bf7e647 into release/v4 Jan 23, 2024
6 checks passed
@nikosdouvlis nikosdouvlis deleted the brk.fix/next-12-compat-fix branch January 23, 2024 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants