-
Notifications
You must be signed in to change notification settings - Fork 419
fix(nextjs): Update imports to avoid Node.js build warnings on edge runtime #3661
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
Conversation
🦋 Changeset detectedLatest commit: 00b7447 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 |
8820281 to
8d49c3a
Compare
AsyncLocalStorage as global for edge runtime AsyncLocalStorage as global for edge runtime
f3eb38d to
8d49c3a
Compare
AsyncLocalStorage as global for edge runtimeAsyncLocalStorage for edge runtime
AsyncLocalStorage for edge runtime| import { logger } from '@clerk/shared'; | ||
| import { handleValueOrFn } from '@clerk/shared/handleValueOrFn'; | ||
| import { isDevelopmentFromSecretKey } from '@clerk/shared/keys'; | ||
| import { logger } from '@clerk/shared/logger'; |
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.
This fixes the build warnings where MessageEvent was being imported during the edge runtime, since it was being resolved on the root of @clerk/shared.
| @@ -1,3 +1,5 @@ | |||
| import { AsyncLocalStorage } from 'node:async_hooks'; | |||
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.
By using node:async_hooks, it uses the AsyncLocalStorage polyfill from Next.js. TBH it's a controversy from what Vercel docs mention, in which async_hooks would also be polyfilled: https://vercel.com/docs/functions/runtimes/edge-runtime#compatible-node.js-modules
23e238e to
00b7447
Compare

Description
Fixes #3660
AsyncLocalStorageavailable as a global polyfill for the edge runtime, instead of importing from Node.js: https://nextjs.org/docs/pages/api-reference/edge#nextjs-specific-polyfillsloggerfrom nested importChecklist
npm testruns as expected.npm run buildruns as expected.Type of change