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

Vite plugin: 'use-sync-external-store/shim/index.js' is not aliased, dev server crashes with react-aria

Aperta Adatta ai principianti
#67 0 commenti 1 reazione 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
90/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
react, typescript, vite
Ambito
build-system

Direzione di ricerca

Inizia da packages/redact/src/vite/index.ts ed esamina le voci ALIASES per use-sync-external-store/shim. Aggiungi lì i due alias di percorso dei file suggeriti, poi verifica che entrambi gli specificatori vengano risolti in @tanstack/redact nel server di sviluppo Vite. Il lavoro è completato quando la riproduzione non va più in crash a causa dell’export useSyncExternalStore mancante.

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

Descrizione

Summary

react-aria, react-aria-components and react-stately import the use-sync-external-store shim by its file path:

import { useSyncExternalStore } from "use-sync-external-store/shim/index.js";

The Vite plugin alias table does not contain this specifier. It contains use-sync-external-store/shim, but not use-sync-external-store/shim/index.js. The import therefore resolves to the real CJS shim.

In the dev server, the plugin also excludes use-sync-external-store* from optimizeDeps. The browser then loads the raw CJS file as ESM, and the root render crashes:

SyntaxError: The requested module '/node_modules/use-sync-external-store/shim/index.js?v=…'
does not provide an export named 'useSyncExternalStore'

The production build does not crash, because Rolldown converts the CJS file.

Reproduction
  1. Create a Vite + React SPA with redact() in plugins.
  2. Render any component from react-aria-components that uses useSyncExternalStore. Examples: Sheet, a toast region (useToastState), or a collection component (CollectionBuilder).
  3. Run vite (the dev server) and open the page.

Result: blank page and the error above. Expected: the shim resolves to @tanstack/redact, the same as use-sync-external-store/shim.

Workaround

Add the specifier as an alias in the app's vite.config.ts:

resolve: {
  alias: {
    "use-sync-external-store/shim/index.js": "@tanstack/redact",
  },
},

With this alias, our full e2e suite (66 Playwright tests) passes on Redact.

Suggested fix

Add these entries to ALIASES in packages/redact/src/vite/index.ts, before use-sync-external-store/shim:

'use-sync-external-store/shim/index.js': '@tanstack/redact',
'use-sync-external-store/index.js': '@tanstack/redact',
Versions
  • @tanstack/redact 0.2.0. The alias table on main (d56d87cb) has the same gap.
  • vite 8.3.4
  • react-aria 3.53.1, react-aria-components 1.22.1, react-stately 3.51.0
Lingua principale
TypeScript
Stelle
408
Fork
13
Merge medio
1h 44m
PR unite (30g)
21

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 TanStack/redact

Tutte le issue di TanStack/redact

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.