@clerk/nextjs: no subpath export for ClerkProvider, so the root barrel puts every UI component into an App Router app's first load
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 56/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- nextjs, react, typescript
- Área
- build-system, frontend, performance
Línea de trabajo
Comienza inspeccionando el package exports map y las entradas existentes de dist/esm/components.server.js y dist/esm/package.json; después, compáralas con dist/esm/index.js. Añade un subpath o export react-server compatible para ClerkProvider y Show sin el UI barrel, y verifícalo con la medición del App Router production build descrita en el issue.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Package
@clerk/nextjs@7.7.0 (re-checked against 7.7.7 — unchanged)
What
An App Router root layout must import ClerkProvider, and the only supported specifier is the root barrel:
// app/layout.tsx — a Server Component
import { ClerkProvider } from "@clerk/nextjs";
dist/esm/index.js statically imports three "use client" modules — client-boundary/uiComponents, client-boundary/controlComponents, client-boundary/hooks — alongside the provider. A Server Component importing a "use client" barrel registers every export of that barrel as a client reference, whether or not it renders them. So an app that renders one <UserButton> ships the client wrappers for PricingTable, OrganizationProfile, OrganizationSwitcher, APIKeys, Waitlist and the rest, on every route.
The package's own exports map has no client-component subpath and no wildcard:
".", "./server", "./errors", "./internal", "./webhooks", "./experimental", "./legacy", "./types"
/internal is not an alternative — it imports client-boundary/uiComponents itself.
The provider is already clean internally
ClerkProvider resolves through the package-private #components condition (declared in dist/esm/package.json) to dist/esm/components.server.js, which imports none of the UI modules:
// dist/esm/components.server.js
import { ClerkProvider } from "./app-router/server/ClerkProvider";
import { Show } from "./app-router/server/controlComponents";
A specifier landing there would give an App Router app the provider without the UI barrel. There just isn't one — #components is package-private and the root exports map has no wildcard.
Measured
Nine cold production builds of a Next.js 16 App Router app (Turbopack, Cache Components), NEXT_SERVER_ACTIONS_ENCRYPTION_KEY pinned so builds are byte-comparable; the reverted tree rebuilt byte-identical to the baseline:
| configuration | total client JS (gz) | Δ |
|---|---|---|
| as shipped today | 579,569 | — |
provider aliased to components.server.js + every Clerk component behind one client module |
574,801 | −4,768 |
That −4,768 gz (0.82% of the app's client JS) is what a supported subpath would buy for free. Reaching it today needs a bundler alias onto dist/esm/components.server.js — a path outside your exports map, through a condition the alias bypasses — which we measured, priced and then declined to ship: a rename on your side fails our build loudly (fine), but a content change fails nothing and would land at runtime in the root layout of every page.
Ask
A supported subpath that exports ClerkProvider (and Show) without the client-component barrel — e.g. @clerk/nextjs/provider, or simply exposing what #components already resolves to under the react-server condition. Naming it in exports is most of the work; the module exists.
Related
Filed alongside a request for sideEffects: false on @clerk/react and @clerk/shared, which is the other half — with a subpath but without that flag, @clerk/react's rollup-merged dist still carries the UI implementations into the provider's chunk.
- Lenguaje dominante
- TypeScript
- Estrellas
- 1.8k
- Forks
- 472
- Merge medio
- 2 d 12 h
- PR fusionados (30 d)
- 222
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de clerk/javascript
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
clerk/javascript#9611 · 1 comentario ·
-
clerk/javascript#9891 · 1 asignado ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 64/100
clerk/javascript#9775 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
clerk/javascript#9770 · 3 comentarios ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
clerk/javascript#9667 · 1 comentario ·
Todos los issues de clerk/javascript
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
mksglu/context-mode#1200 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
jaegertracing/jaeger-ui#4506 ·
-
area:desktop area:ui bug platform:macos
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
anthropics/claude-code#96687 ·
-
good first issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
AOSSIE-Org/DebateAI#582 · 2 comentarios ·