waku: MUI React Component Library / Fails in all modes
pnpm waku dev or pnpm waku dev --with-ssr - looks like a problem in ViteJS:
"@mui/material": "^5.15.6",
"@emotion/react": "^11.11.3",
"@emotion/styled": "^11.11.0",
"vite": "^5.0.12",
"waku": "0.19.1"
Repo to reproduce error: https://github.com/aheissenberger/waku-mui
Error:
ready: Listening on http://localhost:3000/
22:46:22 [vite] Pre-transform error: [vite] The "code" property of ModuleInfo is not supported.
22:46:23 [vite] Error when evaluating SSR module /src/templates/home-page.tsx: failed to import "/node_modules/.pnpm/@mui+material@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_reac_6uvakbjdbr4jjappweoxbh4ft4/node_modules/@mui/material/Button/index.js"
|- Error: [vite] The "code" property of ModuleInfo is not supported.
at Object.get (file:///waku-mui/node_modules/.pnpm/vite@5.0.12/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:63625:19)
at load (file:///waku-mui/node_modules/.pnpm/waku@0.19.1_react-dom@18.3.0-canary-b30030471-20240117_react-server-dom-webpack@18.3.0-canary_gs5p533tfweocikxyqduoft2v4/node_modules/waku/dist/lib/plugins/vite-plugin-rsc-transform.js:45:21)
at async parseExportNamesInto (file:///waku-mui/node_modules/.pnpm/react-server-dom-webpack@18.3.0-canary-b30030471-20240117_react-dom@18.3.0-canary-b30030471-2_t4eugufsfo5omzsdzuea64ykkm/node_modules/react-server-dom-webpack/esm/react-server-dom-webpack-node-loader.production.min.js:222:33)
at async transformClientModule (file:///waku-mui/node_modules/.pnpm/react-server-dom-webpack@18.3.0-canary-b30030471-20240117_react-dom@18.3.0-canary-b30030471-2_t4eugufsfo5omzsdzuea64ykkm/node_modules/react-server-dom-webpack/esm/react-server-dom-webpack-node-loader.production.min.js:282:3)
at async Module.load (file:///waku-mui/node_modules/.pnpm/react-server-dom-webpack@18.3.0-canary-b30030471-20240117_react-dom@18.3.0-canary-b30030471-2_t4eugufsfo5omzsdzuea64ykkm/node_modules/react-server-dom-webpack/esm/react-server-dom-webpack-node-loader.production.min.js:414:20)
at async TransformContext.transform (file:///waku-mui/node_modules/.pnpm/waku@0.19.1_react-dom@18.3.0-canary-b30030471-20240117_react-server-dom-webpack@18.3.0-canary_gs5p533tfweocikxyqduoft2v4/node_modules/waku/dist/lib/plugins/vite-plugin-rsc-transform.js:60:30)
at async Object.transform (file:///waku-mui/node_modules/.pnpm/vite@5.0.12/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:64063:30)
at async loadAndTransform (file:///waku-mui/node_modules/.pnpm/vite@5.0.12/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:49741:29)
at async instantiateModule (file:///waku-mui/node_modules/.pnpm/vite@5.0.12/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:50759:10)
ppm waku build
Error:
pnpm waku build
vite v5.0.12 building SSR bundle for production...
✓ 285 modules transformed.
✓ built in 1.05s
vite v5.0.12 building SSR bundle for production...
✓ 31 modules transformed.
[commonjs--resolver] Duplicate export "default"
file: /waku-mui/node_modules/.pnpm/@mui+system@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_react@_vcpncwiim6d7zx7zuiikm6a2vm/node_modules/@mui/system/esm/GlobalStyles/index.js:3:0
1: 'use client';
2:
3: export { default } from './GlobalStyles';
^
4: export * from './GlobalStyles';
file:///waku-mui/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:337
base = Object.assign(new Error(base.message), base);
^
Error [RollupError]: Duplicate export "default"
at error (file:///waku-mui/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:337:30)
at Module.error (file:///waku-mui/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/node-entry.js:12781:16)
at Module.assertUniqueExportName (file:///waku-mui/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/node-entry.js:13249:18)
at Module.addExport (file:///waku-mui/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/node-entry.js:13255:18)
at ExportDefaultDeclaration.initialise (file:///waku-mui/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/node-entry.js:9569:28)
at new NodeBase (file:///waku-mui/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/node-entry.js:4623:14)
at new ExportDefaultDeclaration (file:///waku-mui/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/node-entry.js:9557:1)
at Program.parseNode (file:///waku-mui/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/node-entry.js:4734:27)
at new NodeBase (file:///waku-mui/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/node-entry.js:4622:14)
at new Program (file:///waku-mui/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/node-entry.js:11012:9) {
code: 'PLUGIN_ERROR',
id: '/waku-mui/node_modules/.pnpm/@mui+system@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_react@_vcpncwiim6d7zx7zuiikm6a2vm/node_modules/@mui/system/esm/GlobalStyles/index.js',
pos: 631,
loc: {
column: 0,
file: '/waku-mui/node_modules/.pnpm/@mui+system@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_react@_vcpncwiim6d7zx7zuiikm6a2vm/node_modules/@mui/system/esm/GlobalStyles/index.js',
line: 3
},
frame: "1: 'use client';\n" +
'2: \n' +
"3: export { default } from './GlobalStyles';\n" +
' ^\n' +
"4: export * from './GlobalStyles';",
pluginCode: 'DUPLICATE_EXPORT',
plugin: 'commonjs--resolver',
hook: 'resolveId',
watchFiles: [
'/waku-mui/node_modules/.pnpm/react@18.3.0-canary-b30030471-20240117/node_modules/react/jsx-runtime.js',
'/waku-mui/node_modules/.pnpm/@mui+material@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_reac_6uvakbjdbr4jjappweoxbh4ft4/node_modules/@mui/material/Button/index.js',
'/waku-mui/node_modules/.pnpm/@mui+utils@5.15.6_@types+react@18.2.48_react@18.3.0-canary-b30030471-20240117/node_modules/@mui/utils/esm/index.js',
'/waku-mui/node_modules/.pnpm/waku@0.19.1_react-dom@18.3.0-canary-b30030471-20240117_react-server-dom-webpack@18.3.0-canary_gs5p533tfweocikxyqduoft2v4/node_modules/waku/dist/client.js',
'/waku-mui/node_modules/.pnpm/@mui+material@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_reac_6uvakbjdbr4jjappweoxbh4ft4/node_modules/@mui/material/Button/Button.js',
'/waku-mui/node_modules/.pnpm/@mui+utils@5.15.6_@types+react@18.2.48_react@18.3.0-canary-b30030471-20240117/node_modules/@mui/utils/esm/useId/index.js',
'/waku-mui/node_modules/.pnpm/@mui+utils@5.15.6_@types+react@18.2.48_react@18.3.0-canary-b30030471-20240117/node_modules/@mui/utils/esm/useForkRef/index.js',
'/waku-mui/node_modules/.pnpm/@mui+utils@5.15.6_@types+react@18.2.48_react@18.3.0-canary-b30030471-20240117/node_modules/@mui/utils/esm/useEventCallback/index.js',
'/waku-mui/node_modules/.pnpm/@mui+utils@5.15.6_@types+react@18.2.48_react@18.3.0-canary-b30030471-20240117/node_modules/@mui/utils/esm/useEnhancedEffect/index.js',
'/waku-mui/node_modules/.pnpm/waku@0.19.1_react-dom@18.3.0-canary-b30030471-20240117_react-server-dom-webpack@18.3.0-canary_gs5p533tfweocikxyqduoft2v4/node_modules/waku/dist/router/client.js',
'/waku-mui/node_modules/.pnpm/@mui+utils@5.15.6_@types+react@18.2.48_react@18.3.0-canary-b30030471-20240117/node_modules/@mui/utils/esm/useEnhancedEffect/useEnhancedEffect.js',
'/waku-mui/node_modules/.pnpm/@mui+utils@5.15.6_@types+react@18.2.48_react@18.3.0-canary-b30030471-20240117/node_modules/@mui/utils/esm/usePreviousProps.js',
'/waku-mui/node_modules/.pnpm/@mui+utils@5.15.6_@types+react@18.2.48_react@18.3.0-canary-b30030471-20240117/node_modules/@mui/utils/esm/useControlled/index.js',
'/waku-mui/node_modules/.pnpm/@mui+utils@5.15.6_@types+react@18.2.48_react@18.3.0-canary-b30030471-20240117/node_modules/@mui/utils/esm/useIsFocusVisible.js',
'/waku-mui/node_modules/.pnpm/@mui+utils@5.15.6_@types+react@18.2.48_react@18.3.0-canary-b30030471-20240117/node_modules/@mui/utils/esm/useForkRef/useForkRef.js',
'/waku-mui/node_modules/.pnpm/@mui+system@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_react@_vcpncwiim6d7zx7zuiikm6a2vm/node_modules/@mui/system/esm/index.js',
'/waku-mui/node_modules/.pnpm/@mui+utils@5.15.6_@types+react@18.2.48_react@18.3.0-canary-b30030471-20240117/node_modules/@mui/utils/esm/useId/useId.js',
'/waku-mui/node_modules/.pnpm/@mui+utils@5.15.6_@types+react@18.2.48_react@18.3.0-canary-b30030471-20240117/node_modules/@mui/utils/esm/useEventCallback/useEventCallback.js',
'/waku-mui/node_modules/.pnpm/@mui+utils@5.15.6_@types+react@18.2.48_react@18.3.0-canary-b30030471-20240117/node_modules/@mui/utils/esm/useControlled/useControlled.js',
'/waku-mui/node_modules/.pnpm/react-server-dom-webpack@18.3.0-canary-b30030471-20240117_react-dom@18.3.0-canary-b30030471-2_t4eugufsfo5omzsdzuea64ykkm/node_modules/react-server-dom-webpack/server.edge.js',
'/waku-mui/node_modules/.pnpm/@mui+system@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_react@_vcpncwiim6d7zx7zuiikm6a2vm/node_modules/@mui/system/esm/GlobalStyles/index.js',
'/waku-mui/node_modules/.pnpm/@mui+styled-engine@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_react@18.3.0-canary-b30030471-20240117/node_modules/@mui/styled-engine/index.js',
'/waku-mui/node_modules/.pnpm/@mui+system@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_react@_vcpncwiim6d7zx7zuiikm6a2vm/node_modules/@mui/system/esm/Box/index.js',
'/waku-mui/node_modules/.pnpm/@mui+system@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_react@_vcpncwiim6d7zx7zuiikm6a2vm/node_modules/@mui/system/esm/createBox.js',
'/waku-mui/node_modules/.pnpm/@mui+system@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_react@_vcpncwiim6d7zx7zuiikm6a2vm/node_modules/@mui/system/esm/useThemeProps/index.js',
'/waku-mui/node_modules/.pnpm/@mui+system@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_react@_vcpncwiim6d7zx7zuiikm6a2vm/node_modules/@mui/system/esm/useThemeWithoutDefault.js',
'/waku-mui/node_modules/.pnpm/@mui+system@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_react@_vcpncwiim6d7zx7zuiikm6a2vm/node_modules/@mui/system/esm/ThemeProvider/index.js',
'/waku-mui/node_modules/.pnpm/@mui+system@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_react@_vcpncwiim6d7zx7zuiikm6a2vm/node_modules/@mui/system/esm/Unstable_Grid/index.js',
'/waku-mui/node_modules/.pnpm/@mui+system@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_react@_vcpncwiim6d7zx7zuiikm6a2vm/node_modules/@mui/system/esm/Unstable_Grid/Grid.js',
'/waku-mui/node_modules/.pnpm/@mui+material@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_reac_6uvakbjdbr4jjappweoxbh4ft4/node_modules/@mui/material/styles/styled.js',
'/waku-mui/node_modules/.pnpm/@mui+system@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_react@_vcpncwiim6d7zx7zuiikm6a2vm/node_modules/@mui/system/esm/Container/index.js',
'/waku-mui/node_modules/.pnpm/@mui+system@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_react@_vcpncwiim6d7zx7zuiikm6a2vm/node_modules/@mui/system/esm/useTheme.js',
'/waku-mui/node_modules/.pnpm/@mui+system@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_react@_vcpncwiim6d7zx7zuiikm6a2vm/node_modules/@mui/system/esm/Stack/Stack.js',
'/waku-mui/node_modules/.pnpm/@mui+system@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_react@_vcpncwiim6d7zx7zuiikm6a2vm/node_modules/@mui/system/esm/GlobalStyles/GlobalStyles.js',
'/waku-mui/node_modules/.pnpm/@mui+system@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_react@_vcpncwiim6d7zx7zuiikm6a2vm/node_modules/@mui/system/esm/Stack/index.js',
'/waku-mui/node_modules/.pnpm/@mui+system@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_react@_vcpncwiim6d7zx7zuiikm6a2vm/node_modules/@mui/system/esm/Box/Box.js',
'/waku-mui/node_modules/.pnpm/@mui+system@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_react@_vcpncwiim6d7zx7zuiikm6a2vm/node_modules/@mui/system/esm/useThemeProps/useThemeProps.js',
'/waku-mui/node_modules/.pnpm/@mui+system@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_react@_vcpncwiim6d7zx7zuiikm6a2vm/node_modules/@mui/system/esm/ThemeProvider/ThemeProvider.js',
'/waku-mui/node_modules/.pnpm/@mui+system@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_react@_vcpncwiim6d7zx7zuiikm6a2vm/node_modules/@mui/system/esm/Container/Container.js',
'/waku-mui/node_modules/.pnpm/@mui+material@5.15.6_@emotion+react@11.11.3_@emotion+styled@11.11.0_@types+react@18.2.48_reac_6uvakbjdbr4jjappweoxbh4ft4/node_modules/@mui/material/styles/defaultTheme.js'
]
}
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 40 (26 by maintainers)
Commits related to this issue
- fix(website): hack next-mdx-remote with vite config (DEV only) (#779) Hmm, this is going to be a big problem with ESM/CJS compat... Maybe related: #421, #428 — committed to wakujs/waku by dai-shi 2 years ago
- fix(website): hack next-mdx-remote with vite config (DEV only) (#779) Hmm, this is going to be a big problem with ESM/CJS compat... Maybe related: #421, #428 — committed to himself65/waku by dai-shi 2 years ago
Everything seems to work well now on latest versions 🚀
https://stackblitz.com/~/github.com/tylersayshi/waku-mui
closing as complete. Thanks Jan!
Hi, just to let you know now all packages across the company have an updated package layout in their latest major version that correctly supports dual mode ESM-CJS, so we’ve closed https://github.com/mui/material-ui/issues/43938. Thank you for your patience.
@stunaz Ah, I see. You were suggesting a potential fix. Waku is slightly different from TanStack Start, like we use Vite “ssr” for both SSR (html) and RSC (json like payload). Thanks anyway.
@tylersayshi When you have time, can you look into this? https://github.com/wakujs/waku/issues/428#issuecomment-2385134926 is my last status, but things might have changed since then.
for now, we’ll wait and monitor the progress of https://github.com/mui/material-ui/issues/43938 - it’s in progress on the MUI project board which is very promising https://github.com/orgs/mui/projects/23 (thanks olivier and team!)
If we have similar interop issues with cjs libraries, maybe we could consider recommending things like node@23 import cjs interop support: https://nodejs.org/api/esm.html#interoperability-with-commonjs
Removing our use of
importin dev could be re-evaluated if we see other issues and if the first two items here don’t work. I’m personally hoping we can help nudge our slice of the ecosystem along to esm if we can.I’m investigating these issues in @lazarv/react-server and my results might help you out here too as it’s possible that some workarounds work with Waku too.
When I import a MUI component as default, I get a React error about the imported component:
This is because the
Buttonimport for me is an object like this:When I’m importing the Button component from the main @mui/material module, it works!
Surely this is not ideal, but at least works even with SSR. Based on this finding someone might have a solution for this for the import to work properly, but it seems like some issue with Vite and Material UI, maybe some exports and conditions issue on Material UI’s side.
I also tried this out using my
ClientOnlycomponent which is just skipping SSR for it’s children and only renders children on the client after hydration. Using this works fine in any way, but this is just plain old Vite in that environment.I will test it against the current version today and will report the progress.
Currently busy with other projects but I will give it some time and check how it works outside Waku and with NextJS App folder. I won’t start before mid of next week.
Well, the dev issue is because emotion/mui are not supporting RSC properly.
https://github.com/emotion-js/emotion/issues/2928 https://mui.com/material-ui/integrations/nextjs/
Let me see the build error now.