-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
[material-ui] Fix ThemeOptions and createTheme* cyclic dependency
#47007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Netlify deploy previewhttps://deploy-preview-47007--material-ui.netlify.app/ Bundle size report
|
createTheme* cyclic dependencyThemeOptions and createTheme* cyclic dependency
|
@sai6855 Can you check this PR on your side. |
|
I followed your comment, modified my design system's package.json, and can confirm that the heapUsed is now back to a normal level like below. I really appreciate you resolving this significant issue. As I was studying the problem, I wanted to ensure I fully understood the root cause. Could you please confirm if my understanding of the original cyclic dependency is correct?
This effectively created a circular reference where each file required a type from the other. Is this an accurate summary? Thank you again for your time and the excellent fix. |
|
This is great, thank you for the investigation and fix! |
I am 99% sure that's the root cause. Thank you so much for the reproduction repo, it helps a ton. |
|
@siriwatknp hey, looks like these changes broke augmentation for custom theme option overrides. This is now produces errors:
declare module '@mui/material/styles' {
interface Shape {
borderRadius: number
borderRadiusSecondary: number // custom prop
}
interface Theme {
shape: Shape
}
interface ThemeOptions {
shape?: Partial<Shape>
}
} |
|
@chybisov, did you find a solution? |
|
@plevavas nope, still on the previous version before this change. @siriwatknp could you please advise here? 🙏 Thank you! |
I'm looking into it |
|
@chybisov Can you try this build // package.json
"@mui/material": "https://pkg.pr.new/mui/material-ui/@mui/material@63cf433" |



closes #46908
The root cause the the options type of the
createThemeis mixing betweencreateThemeNoVarsandcreateThemeWithVarsoptions causing complex type inferences for webpack as demonstrated by https://github.com/nvrtmd/mui-v7-memory-issue-reproSolution
ThemeOptionsby relying on thecreateThemeWithVarsoptions (already extending thecreateThemeNoVars).The fix also enhancing the
ThemeOptionsto be a complete version for users who import the type to build up theme options outside of thecreateTheme.Test
npm run build:create-theme