@clerk/react and @clerk/shared do not declare sideEffects: false, which blocks tree-shaking through ClerkProvider
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- nextjs, react, typescript
- Ambito
- build-system, frontend, performance
Direzione di ricerca
Inizia ispezionando i manifest dei pacchetti pubblicati per @clerk/react e @clerk/shared, quindi traccia il modo in cui @clerk/react produce dist/ClerkProvider-CNl0Jmp6.mjs. Verifica se i pacchetti sono privi di effetti collaterali e come il provider viene unito ai componenti UI. Il lavoro è completato quando i metadati sono corretti e, se si procede in questa direzione, il provider non include più codice UI non correlato; esegui nuovamente la misurazione riportata del bundle di produzione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Package
@clerk/react@6.13.1, @clerk/shared@4.27.1 (reached via @clerk/nextjs@7.7.0)
What
@clerk/nextjs declares "sideEffects": false. Neither of the two packages it stands on does — @clerk/react and @clerk/shared both omit the field entirely, so a bundler must assume every module in them has side effects and cannot drop unreachable exports.
$ node -e "for (const p of ['@clerk/react','@clerk/shared','@clerk/nextjs'])
console.log(p, require(p+'/package.json').sideEffects)"
@clerk/react undefined
@clerk/shared undefined
@clerk/nextjs false
Why it matters downstream
Measured on a Next.js 16 App Router app (Turbopack, Cache Components, @clerk/nextjs@7.7.0), across nine cold production builds:
@clerk/nextjsputs 66,806 bytes gzipped into first load, on every route, becauseClerkProviderlives in the root layout.- With every Clerk UI component deleted from the app — no
<UserButton>, no<SignIn>, no<SignUp>— and the provider resolved past the root barrel, 51,910 gz still remains. That is the floor:ClerkProvideralone.
Two things put it there, and the sideEffects gap is one:
- No
sideEffects: falseon@clerk/react/@clerk/shared, so nothing unreachable can be dropped. @clerk/react's dist is rollup-merged —dist/ClerkProvider-CNl0Jmp6.mjsis a single 59,673-byte file holding the provider and the UI component implementations. Even withsideEffects: false, importing the provider pulls that whole file, because the merge happened at publish time rather than at the consumer's bundler.
So (1) alone is necessary but may not be sufficient — (2) would need the provider split out of the shared chunk for the flag to actually pay. Both together are what would let an app that renders one avatar stop shipping the code for PricingTable, OrganizationProfile, OrganizationSwitcher and the rest.
Ask
Declare "sideEffects": false in @clerk/react and @clerk/shared if it holds (both look side-effect-free from the outside — they are component/hook/util modules), and, if you're open to it, split ClerkProvider out of the merged dist chunk so the flag has something to act on.
Happy to re-run the measurement against a canary if that's useful.
Related
Filed alongside a request for a client-component subpath export on @clerk/nextjs, which is the other half of the same problem for App Router apps.
- Lingua principale
- TypeScript
- Stelle
- 1.8k
- Fork
- 472
- Merge medio
- 2g 12h
- PR unite (30g)
- 222
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di clerk/javascript
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
clerk/javascript#9611 · 1 commento ·
-
clerk/javascript#9891 · 1 assegnatario ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 64/100
clerk/javascript#9775 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
clerk/javascript#9770 · 3 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
clerk/javascript#9667 · 1 commento ·
Tutte le issue di clerk/javascript
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
mksglu/context-mode#1200 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
jaegertracing/jaeger-ui#4506 ·
-
area:desktop area:ui bug platform:macos
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
anthropics/claude-code#96687 ·
-
good first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
AOSSIE-Org/DebateAI#582 · 2 commenti ·