Uh oh!
There was an error while loading. Please reload this page.
fix(nextjs): Update imports to avoid Node.js build warnings on edge runtime - #3661
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
8d49c3aCompareAsyncLocalStorage as global for edge runtime AsyncLocalStorage as global for edge runtimef3eb38d to
8d49c3aCompareAsyncLocalStorage as global for edge runtimeAsyncLocalStorage for edge runtimeAsyncLocalStorage 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.
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.
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
00b7447Compare
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