Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

react-dom declared as a hard dependency instead of peerDependency causes invalid dependency tree on React 18

Aperta Adatta ai principianti
#571 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
84/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
react, typescript
Ambito
frontend

Direzione di ricerca

Inizia da package.json di @asgardeo/react e confronta le voci react e react-dom, quindi rigenera package-lock.json e analizza l’albero delle dipendenze con npm ls react e npm ls react-dom. Verifica la build del pacchetto e conferma che un progetto React 18 non installi più un [email protected] annidato né includa entrambe le versioni del renderer nel proprio bundle di produzione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Type/Bug

@asgardeo/react declares react-dom as a direct dependency (pinned to exactly
19.2.4) while react is a peerDependency accepting >=16.8.0. These two cannot
be satisfied together on a React 18 project: npm resolves react to the app's
18.3.1 and installs a second, nested [email protected] beside it. npm reports
the resulting tree as invalid, and both renderers are included in the
production bundle.

Severity note: this does not crash the app. In a minimal repro it renders
correctly under both vite dev and vite preview, with no console errors,
because the SDK's dist/index.js does not itself import react-dom — so the
mismatched copy is never executed. This is a dependency-hygiene and
bundle-size issue rather than a runtime failure, flagging that explicitly
since a crash report would not reproduce. The mismatched copy is, however,
genuinely broken if anything ever loads it directly:

$ node -e "require('./node_modules/@asgardeo/react/node_modules/react-dom/client')"
TypeError: Cannot read properties of undefined (reading 'S')

React 19's react-dom reads
React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, which
React 18.3.1 does not define.

Observed output — npm ls react (tree marked invalid):

[email protected]
+-- @asgardeo/[email protected]
| +-- @floating-ui/[email protected]
| | +-- @floating-ui/[email protected]
| | | -- [email protected] deduped
| | -- [email protected] deduped
| +-- [email protected]
| | -- [email protected] deduped invalid: "^19.2.4" from node_modules/@asgardeo/react/node_modules/react-dom
| -- [email protected] deduped
+-- [email protected]
`-- [email protected]

npm ls react-dom (two copies):

+-- @asgardeo/[email protected]
| +-- @floating-ui/[email protected]
| | +-- @floating-ui/[email protected]
| | | -- [email protected] deduped
| | -- [email protected] deduped
| -- [email protected]
-- [email protected]

Both renderers reach the production bundle (confirmed by grepping the build
output for each version's internals symbol). Deduplicating them reduces the
bundle from 711,161 to 707,294 bytes (~3.9 kB raw, ~1.3 kB gzip of unused
renderer).

Root cause: react-dom is listed under "dependencies" rather than
"peerDependencies" in @asgardeo/react's package.json:

"dependencies":     { "react-dom": "19.2.4", "@types/react-dom": "19.2.3", ... }
"peerDependencies": { "react": ">=16.8.0", "@types/react": ">=16.8.0" }

An exact 19.x pin for the renderer is incompatible with a >=16.8.0 peer range
for react, since react-dom must match the react it renders with.

Suggested fix: move react-dom and @types/react-dom to peerDependencies,
matching how react and @types/react are already handled.

Workaround used: npm overrides pinning the SDK's react-dom to the app's
own version, plus resolve.dedupe: ["react", "react-dom"] in vite.config.js.
Note: adding the override alone had no effect until the lockfile was
regenerated — the existing package-lock.json kept pinning 19.2.4 even after
npm reported the override as applied.

Lingua principale
TypeScript
Stelle
18
Fork
67
Merge medio
3h 40m
PR unite (30g)
15

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di asgardeo/javascript

Tutte le issue di asgardeo/javascript

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.