material-ui: Next.js build error when using Edge Runtime
Steps to reproduce ๐น
Link to live example:
Steps:
Current behavior ๐ฏ
No response
Expected behavior ๐ค
No response
Context ๐ฆ
No response
Your environment ๐
npx @mui/envinfo
Don't forget to mention which browser you used.
Output from `npx @mui/envinfo` goes here.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 26 (4 by maintainers)
Commits related to this issue
- [utils] Update isPlainObject implementation This update adds support for checking plain object in non-v8/standard runtimes as well (ie vercel edge-runtime) Closes #36574 #39338 — committed to brijeshb42/material-ui by brijeshb42 7 months ago
- [utils] Update isPlainObject implementation This update adds support for checking plain object in non-v8/standard runtimes as well (ie vercel edge-runtime) Closes #36574 #39338 — committed to brijeshb42/material-ui by brijeshb42 7 months ago
@mj12albert thanks for the feedback and for looking at this, Iโve upgraded
emotionand copied the new version of theThemeRegistryfrom the example provided. Unfortunately Iโm still seeing the error in the server logs - only for the routes marked asruntime = edgeerror TypeError: Cannot read properties of undefined (reading 'fontWeightBold')Any updates on this? ๐
Use
createThemebefore passing the theme toThemeProvider.for example,
const appTheme = createTheme(theme);<ThemeProvider theme={appTheme}> <CssBaseline /> {children} </ThemeProvider>I have the same issue. However, in my case, itโs not possible to replicate that in codesandbox because the error seems to only appear on NextJS, using
edgeruntime - which doesnโt seem to be currently supported by the codesandbox engine. - and it seems to be caused by<CssBaseline />The minimum repro step would include
/app/layout.jsThemeRegistry.js/app/test/page.jsThe server log on a request to
/testwould beItโs worth noting that the error doesnโt prevent the page to render
on the clientbut it breaks thessrMy deps
@BartoszJanowski no unfortunately this is still an issue for me and itโs blocking me as it breaks the SSR
@mj12albert do you know if is there any plan of coming with a fix for this?