From 97d59243aa6c0a221ddff9a1a4bc0df520407d3a Mon Sep 17 00:00:00 2001 From: Jacek Date: Mon, 9 Feb 2026 12:24:10 -0600 Subject: [PATCH 1/4] fix(nextjs): Remove webpackIgnore from @clerk/ui dynamic import for Turbopack compatibility --- .../nextjs/src/app-router/client/ClerkProvider.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/nextjs/src/app-router/client/ClerkProvider.tsx b/packages/nextjs/src/app-router/client/ClerkProvider.tsx index cb26236acac..489530b60f6 100644 --- a/packages/nextjs/src/app-router/client/ClerkProvider.tsx +++ b/packages/nextjs/src/app-router/client/ClerkProvider.tsx @@ -93,15 +93,13 @@ const NextClientClerkProvider = (props: NextClerkProviderPr // Resolve ClerkUI for RSC: when the ui prop is serialized through React Server Components, // the ClerkUI constructor is stripped (not serializable). Re-import it on the client. + // This code path only executes when the user explicitly passes `ui={ui}` from @clerk/ui, + // so the package is guaranteed to be installed and resolvable by the bundler. const uiProp = mergedProps.ui as { __brand?: string; ClerkUI?: unknown } | undefined; if (uiProp?.__brand && !uiProp?.ClerkUI) { - // webpackIgnore prevents the bundler from statically resolving @clerk/ui/entry at build time, - // since @clerk/ui is an optional dependency that may not be installed. - // @ts-expect-error - @clerk/ui/entry is resolved by the user's Next.js bundler at runtime, not at package build time + // @ts-expect-error - @clerk/ui is an optional peer dependency, not declared in this package's dependencies // eslint-disable-next-line import/no-unresolved - _resolvedClerkUI ??= import(/* webpackIgnore: true */ '@clerk/ui/entry').then( - (m: { ClerkUI: ClerkUIConstructor }) => m.ClerkUI, - ); + _resolvedClerkUI ??= import('@clerk/ui/entry').then((m: { ClerkUI: ClerkUIConstructor }) => m.ClerkUI); mergedProps.ui = { ...mergedProps.ui, ClerkUI: _resolvedClerkUI }; } From ff62d31030e10c8d970812f3f81e9140a4fdc52a Mon Sep 17 00:00:00 2001 From: Jacek Date: Mon, 9 Feb 2026 12:27:24 -0600 Subject: [PATCH 2/4] chore: Add changeset --- .changeset/fix-turbopack-ui-import.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fix-turbopack-ui-import.md diff --git a/.changeset/fix-turbopack-ui-import.md b/.changeset/fix-turbopack-ui-import.md new file mode 100644 index 00000000000..23b0da028e8 --- /dev/null +++ b/.changeset/fix-turbopack-ui-import.md @@ -0,0 +1,5 @@ +--- +'@clerk/nextjs': patch +--- + +Fix Turbopack compatibility for `ui` prop by removing `webpackIgnore` magic comment from dynamic `@clerk/ui/entry` import. Turbopack does not support `webpackIgnore`, causing the bare module specifier to reach the browser and fail at runtime. From b6b987432eee50b5f72ac3c8241a84a74d627e0d Mon Sep 17 00:00:00 2001 From: Jacek Date: Mon, 9 Feb 2026 12:49:58 -0600 Subject: [PATCH 3/4] fix(nextjs): Add turbopackIgnore alongside webpackIgnore for @clerk/ui dynamic import --- .changeset/fix-turbopack-ui-import.md | 2 +- packages/nextjs/src/app-router/client/ClerkProvider.tsx | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.changeset/fix-turbopack-ui-import.md b/.changeset/fix-turbopack-ui-import.md index 23b0da028e8..05542f5d00f 100644 --- a/.changeset/fix-turbopack-ui-import.md +++ b/.changeset/fix-turbopack-ui-import.md @@ -2,4 +2,4 @@ '@clerk/nextjs': patch --- -Fix Turbopack compatibility for `ui` prop by removing `webpackIgnore` magic comment from dynamic `@clerk/ui/entry` import. Turbopack does not support `webpackIgnore`, causing the bare module specifier to reach the browser and fail at runtime. +Fix Turbopack compatibility for `ui` prop by adding `turbopackIgnore` magic comment alongside `webpackIgnore` on the dynamic `@clerk/ui/entry` import. This prevents both bundlers from statically resolving the optional dependency at build time. diff --git a/packages/nextjs/src/app-router/client/ClerkProvider.tsx b/packages/nextjs/src/app-router/client/ClerkProvider.tsx index 489530b60f6..defc42f2f6e 100644 --- a/packages/nextjs/src/app-router/client/ClerkProvider.tsx +++ b/packages/nextjs/src/app-router/client/ClerkProvider.tsx @@ -93,13 +93,15 @@ const NextClientClerkProvider = (props: NextClerkProviderPr // Resolve ClerkUI for RSC: when the ui prop is serialized through React Server Components, // the ClerkUI constructor is stripped (not serializable). Re-import it on the client. - // This code path only executes when the user explicitly passes `ui={ui}` from @clerk/ui, - // so the package is guaranteed to be installed and resolvable by the bundler. const uiProp = mergedProps.ui as { __brand?: string; ClerkUI?: unknown } | undefined; if (uiProp?.__brand && !uiProp?.ClerkUI) { + // webpackIgnore/turbopackIgnore prevent the bundler from statically resolving @clerk/ui/entry at build time, + // since @clerk/ui is an optional dependency that may not be installed. // @ts-expect-error - @clerk/ui is an optional peer dependency, not declared in this package's dependencies // eslint-disable-next-line import/no-unresolved - _resolvedClerkUI ??= import('@clerk/ui/entry').then((m: { ClerkUI: ClerkUIConstructor }) => m.ClerkUI); + _resolvedClerkUI ??= import(/* webpackIgnore: true */ /* turbopackIgnore: true */ '@clerk/ui/entry').then( + (m: { ClerkUI: ClerkUIConstructor }) => m.ClerkUI, + ); mergedProps.ui = { ...mergedProps.ui, ClerkUI: _resolvedClerkUI }; } From d86d52f7dda8f5c9a96e46c97ffd2e2ddc3ad4b7 Mon Sep 17 00:00:00 2001 From: Jacek Date: Mon, 9 Feb 2026 14:57:02 -0600 Subject: [PATCH 4/4] ci: re-trigger CI