[plugin-rsc] In dev, a server component rendering `@mui/material/Button` breaks the page with "does not provide an export named 'default'"
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 12/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- react, typescript
- Área
- build-system
Línea de trabajo
Start with the client-in-server-package-proxy generation in packages/plugin-rsc/src/plugin.ts (around lines 1538-1555 and 1710-1730) and the packageSources.set call near line 1774, then reproduce with the linked starter in vite dev. Done means a server component importing @mui/material/Button renders in dev as it does in /?client and in the production build, with no prop-types export error.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Claude Opus 5.5 (high effort) wrote this; Claude Opus 5.5 (medium effort) reviewed it.
In vite dev, a server component that renders @mui/material/Button replaces the page with the error boundary, because the browser fails to load MUI's code. A build works. Waku, React Router's RSC Framework Mode and TanStack Start's RSC mode fail the same way in dev.
How to reproduce
The repro is plugin-rsc's starter (pnpm create vite@latest --template rsc) with @mui/material, @emotion/react and @emotion/styled added, and a <Button variant="contained"> in src/root.tsx: https://github.com/nitedani-agent/plugin-rsc-repro-inner-use-client-cjs
pnpm i && pnpm dev, then open http://localhost:5173/- You see the starter's error boundary, "Caught an unexpected error", and the console has:
SyntaxError: The requested module '/node_modules/.pnpm/[email protected]/node_modules/prop-types/index.js?v=414bb9ec' does not provide an export named 'default' - I expected the page with the MUI button, as
pnpm build && pnpm previewshows, and as http://localhost:5173/?client shows in dev, where the sameButtoncomes from a"use client"file of the app (src/client-mui-button.tsx).
It happens in vite dev, cold or warm cache, when all three hold:
- A server component imports a package path whose file has no
"use client", but re-exports by a relative path a file that has one.@mui/material/ButtonisButton/index.mjs, which re-exports./Button.mjs. When the imported file is itself the"use client"file, it works. - That inner
"use client"file imports a CommonJS package (prop-typesinButton.mjs). When it imports only ESM files andreact, which Vite already pre-bundles, it works. A two-file package importingreact-isfails the same way (isValidElementType). - The import is in a server component. The same import in a
"use client"file of the app (/?client) works.
Each framework's official RSC starter with the same page:
| App, with a server component rendering the Button | vite dev (cold and warm) |
Build, then start |
|---|---|---|
| This repro, plugin-rsc 0.5.38 | error boundary | works |
| Waku 1.0.0-rc.4 (plugin-rsc 0.5.38) | Waku's error text replaces the page | works |
| React Router 8.5.1, RSC Framework Mode (plugin-rsc 0.5.38) | "Oops!" error boundary | works on plugin-rsc 0.5.35 ¹ |
| TanStack Start 1.169.4, RSC (plugin-rsc 0.5.38) | "Something went wrong!" | works |
| Next.js 16.4.3, webpack and Turbopack dev, Turbopack build (no plugin-rsc) | works | works |
All four plugin-rsc apps show the same prop-types error. ¹ React Router's build fails on plugin-rsc 0.5.36+ for an unrelated reason (remix-run/react-router#15671).
@vitejs/plugin-rsc 0.5.38, @vitejs/plugin-react 6.1.2, vite 8.3.5
react, react-dom 19.3.1, @mui/material 9.5.0, @emotion/react 11.14.0, @emotion/styled 11.14.1
Node 26.12.1, Linux, pnpm 12.15.0
plugin-rsc's plugin.ts is the same on main (304a92a) as in 0.5.38
plugin-rsc records a package source only for the file a bare import resolves to (packageSources.set). The inner Button.mjs has none, so in dev the browser gets it through client-in-server-package-proxy (plugin.ts#L1538-L1555), which is export * from "<absolute path>" (#L1710-L1730). Vite doesn't add a new dependency to the pre-bundle when a file in node_modules imports it (resolve.ts#L835-L856), and nothing else pre-bundles prop-types here, so it reaches the browser as CommonJS.
Waku and TanStack Start print the "inconsistently optimized" warning for Button.mjs (#L1477-L1490), but its advice doesn't help: with optimizeDeps: { exclude: ['@mui/material'] } the repro fails with the same error. vike-react-rsc works around it by pre-bundling such a file in the client environment (clientInServerPackageDeps.ts).
#1207 reports a different failure in the same client-in-server-package-proxy.
- Lenguaje dominante
- TypeScript
- Estrellas
- 1.2k
- Forks
- 287
- Merge medio
- 1 d 17 h
- PR fusionados (30 d)
- 19
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la 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 vitejs/vite-plugin-react
-
plugin-rsc: a client reference's CSS is linked before the CSS of the chunks it imports (build)Posiblemente ocupada @wozhenbang2004 la tomó hace 7 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
vitejs/vite-plugin-react#1570 ·
Los mantenedores suelen responder en 1 día
-
pending triage
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
vitejs/vite-plugin-react#1581 ·
Los mantenedores suelen responder en 1 día
-
[plugin-rsc] Build exits 0, but the app fails at runtime: a server action imported only by browser code is missing from the RSC buildPosiblemente ocupada @NeilPant la tomó hace 4 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
vitejs/vite-plugin-react#1578 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
vitejs/vite-plugin-react#1577 ·
Los mantenedores suelen responder en 1 día
-
[plugin-rsc] inline "use server" function declarations lose hoisting and throw TDZ ReferenceErrorPosiblemente ocupada @draarivpatel-ui la tomó hace 3 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
vitejs/vite-plugin-react#1566 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de vitejs/vite-plugin-react
Issues similares
-
Resources: New templates ofAbiertoresources
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
railmapgen/rmg-templates#2703 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
witchesofthehill/manabrew#1309 ·
Los mantenedores suelen responder en 1 día
-
good first issue help wanted
Dificultad 2/5 Menos de una hora Aptitud para principiantes 86/100
Intelligenza-Umana/intelligenza-umana-web#16 ·
Los mantenedores suelen responder en 1 día
-
enhancement priority: high size: XS
Dificultad 2/5 1-3 horas Aptitud para principiantes 90/100
Los mantenedores suelen responder en 1 día