-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[core] Support @mui/material@6
peer dependency
#14142
Changes from all commits
b11d987
e6456ff
b521dce
c30d0b5
fb12801
29c5ec4
1e4d2c1
b198bcb
7e4e8c7
0ef6096
080e02c
38a27b4
f1ca4a5
e9f9c0f
4a90723
5fb0be8
9c9bece
ff76fa7
658db02
13299eb
4210fbe
0e7395b
706969e
3ea45df
52753e9
70a5b1d
0fd9edb
938c714
1ef093e
367a893
6d8c54e
2f39b71
f3b885b
5115974
f8a13ab
8a5b09f
4080545
c14d7f7
6ccf1b8
1e43dc0
683a4d7
511a9b4
69412eb
bf0c1be
fbbcd55
9933919
8734cc5
0df4c92
bb4ed81
1cdb9d2
052064d
28878a2
5f387e6
c63a240
e7e1ded
d43e721
bf97234
32ef7c5
88fefcd
8455ec7
9f509d4
65ba268
9c6b41d
cbf3d26
52004b4
03793d1
ec08b52
3ce39ea
8175906
4663687
d5694b9
e03bf63
33b61ac
5c0267c
1a9b909
e8ed9c9
cc54863
10684a9
30ba53b
8bc293b
983e44e
a7789df
6fc6b5f
2856ca6
4fa883e
30b0113
27719dd
6262ce2
e84a016
0fdb1a7
ae64e19
567b805
087882a
20b8a85
8fa45f1
555d8e1
af2f7f3
98fcced
5932ead
9b8d679
c045f74
ba041e2
e5650dd
ddcb5c7
442ad04
9234725
00d0080
6e5c397
767d9f1
6335c86
b88a0aa
3ef28ea
9d35f08
efcf5e6
ad1ef0a
540d383
39805f5
af8eefe
054893f
e64adb1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,14 @@ commands: | |
# log a patch for maintainers who want to check out this change | ||
git --no-pager diff HEAD | ||
|
||
- when: | ||
condition: | ||
equal: [material-ui-v6, << pipeline.parameters.workflow >>] | ||
steps: | ||
- run: | ||
name: Install @mui/material@next | ||
command: pnpm use-material-ui-v6 | ||
|
||
- when: | ||
condition: << parameters.browsers >> | ||
steps: | ||
|
@@ -248,7 +256,7 @@ jobs: | |
command: pnpm docs:typescript:formatted --disable-cache | ||
- run: | ||
name: '`pnpm docs:typescript:formatted` changes committed?' | ||
command: git add -A && git diff --exit-code --staged | ||
command: git add -A && git diff --exit-code --staged docs/src docs/data | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This step was failing because there were changes to |
||
- run: | ||
name: Tests TypeScript definitions | ||
command: pnpm typescript:ci | ||
|
@@ -383,3 +391,23 @@ workflows: | |
<<: *default-context | ||
react-version: next | ||
name: test_e2e-react@next | ||
|
||
material-ui-v6: | ||
when: | ||
equal: [material-ui-v6, << pipeline.parameters.workflow >>] | ||
jobs: | ||
- test_unit: | ||
<<: *default-context | ||
name: test_unit-material@next | ||
- test_browser: | ||
<<: *default-context | ||
name: test_browser-material@next | ||
- test_regressions: | ||
<<: *default-context | ||
name: test_regressions-material@next | ||
- test_e2e: | ||
<<: *default-context | ||
name: test_e2e-material@next | ||
cherniavskii marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- test_types: | ||
<<: *default-context | ||
name: test_types-material@next |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,8 @@ import Box from '@mui/material/Box'; | |
import { DataGrid, GridToolbar, GridActionsCellItem } from '@mui/x-data-grid'; | ||
import { unstable_joySlots } from '@mui/x-data-grid/joy'; | ||
import { | ||
experimental_extendTheme as materialExtendTheme, | ||
Experimental_CssVarsProvider as MaterialCssVarsProvider, | ||
createTheme, | ||
ThemeProvider as MaterialThemeProvider, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to use the |
||
THEME_ID as MATERIAL_THEME_ID, | ||
} from '@mui/material/styles'; | ||
import { CssVarsProvider as JoyCssVarsProvider } from '@mui/joy/styles'; | ||
|
@@ -18,7 +18,7 @@ import { | |
randomArrayItem, | ||
} from '@mui/x-data-grid-generator'; | ||
|
||
const materialTheme = materialExtendTheme({ | ||
const materialTheme = createTheme({ | ||
components: { | ||
MuiSvgIcon: { | ||
styleOverrides: { | ||
|
@@ -97,7 +97,7 @@ export default function GridJoyUISlots() { | |
}, []); | ||
|
||
return ( | ||
<MaterialCssVarsProvider theme={{ [MATERIAL_THEME_ID]: materialTheme }}> | ||
<MaterialThemeProvider theme={{ [MATERIAL_THEME_ID]: materialTheme }}> | ||
<JoyCssVarsProvider> | ||
<Box sx={{ height: 400, width: '100%' }}> | ||
<DataGrid | ||
|
@@ -133,6 +133,6 @@ export default function GridJoyUISlots() { | |
/> | ||
</Box> | ||
</JoyCssVarsProvider> | ||
</MaterialCssVarsProvider> | ||
</MaterialThemeProvider> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import * as React from 'react'; | ||
import Grid from '@mui/material/Unstable_Grid2'; | ||
import Grid from '@mui/material/Grid'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoiding the use of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This component is for the docs-infra though, why not use v6 / Grid2 here? Not important though, maybe best do to later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because it introduces problems when testing/running our codebase on v5 and v6 of |
||
import { InfoCard } from '@mui/docs/InfoCard'; | ||
import LineAxisRoundedIcon from '@mui/icons-material/LineAxisRounded'; | ||
import DashboardCustomizeRoundedIcon from '@mui/icons-material/DashboardCustomizeRounded'; | ||
|
@@ -45,7 +45,7 @@ export default function ChartFeaturesGrid() { | |
return ( | ||
<Grid container spacing={2}> | ||
{content.map(({ icon, title, link }) => ( | ||
<Grid key={title} xs={12} sm={4}> | ||
<Grid item key={title} xs={12} sm={4}> | ||
<InfoCard dense classNameTitle="algolia-lvl3" link={link} title={title} icon={icon} /> | ||
</Grid> | ||
))} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import materialPackageJson from '@mui/material/package.json'; | ||
import { checkMaterialVersion } from 'test/utils/checkMaterialVersion'; | ||
import packageJson from '../../package.json'; | ||
|
||
checkMaterialVersion({ packageJson, materialPackageJson }); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import materialPackageJson from '@mui/material/package.json'; | ||
import { checkMaterialVersion } from 'test/utils/checkMaterialVersion'; | ||
import packageJson from '../../package.json'; | ||
|
||
checkMaterialVersion({ packageJson, materialPackageJson }); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import materialPackageJson from '@mui/material/package.json'; | ||
import { checkMaterialVersion } from 'test/utils/checkMaterialVersion'; | ||
import packageJson from '../../package.json'; | ||
|
||
checkMaterialVersion({ packageJson, materialPackageJson }); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import materialPackageJson from '@mui/material/package.json'; | ||
import { checkMaterialVersion } from 'test/utils/checkMaterialVersion'; | ||
import packageJson from '../../package.json'; | ||
|
||
checkMaterialVersion({ packageJson, materialPackageJson }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LukasTy
The next tests use material v6 and v5 for
@mui/utils
and@mui/system
, so it's an identical situation.I hoped we could keep using v5 for
@mui/utils
and@mui/system
, but this doesn't play nice with material v6.I can try it the other way around – using v6 of
@mui/utils
and@mui/system
with both v5 and v6 of@mui/material
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe I've mentioned it—I have tried this inverse approach, results are the same... 🙈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm not sure what to do then...
@mui/system
and@mui/utils
are direct dependencies, so we need to declare a specific version there (as opposed to@mui/material
which is a peer dependency).Any ideas?
cc @mui/core
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
useRtl
the problem? AFAIK it hasn't been modified since it was introduced 🤔But yeah, Material UI v6 is not compatible with
@mui/utils
and@mui/system
v5 or vice-versa because of (at least) these v6 changes@mui/system
:Unstable_Grid
->Grid
@mui/utils
:useIsFocusVisible
in favor ofisFocusVisible
scrollLeft
as it was only necessary for IE 11But independent of what MUI X sets its
@mui/utils
and@mui/system
dependencies to, if Material UI v5/v6 sets them to v5/v6, respectively, shouldn't those be used for the Material UI package? I might be wrong, I'm not a package manager resolution expert 😅@Janpot might be able to help us with this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the difference:
@mui/material@5
@mui/material@6
useRtl
returnsfalse
even when RTL is turned on:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Firstly, sorry for being "late to the party".
I stumbled into this problem/realization just before finishing my work day and didn't add a comment. 🙈
It is somewhat wrong, because
@mui/system
is used directly in the packages.Such dependencies should be direct.
Besides, if my memory serves me well unless users will explicitly install
@mui/system
in their apps, they will always see a warning that peer dependency is missing after an installation (even though@mui/material
has it as a direct dependency).I'm not sure we should, given the last comment.
Unless
@mui/material
also does the same. 🙈I wanted to finish reading https://github.com/mui/pigment-css/issues/129 before jumping to any conclusions.
But it seems that the
RtlProvider
is a now a bit of a problem to integrate the multiple major support with. 🙈There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about moving
RtlProvider
inside@mui/private-theming
(a dependency of MUI System) in v5 and pin the version to MUI system?This way the
RtlProvider
will be the same context.@mui/private-theming
has not been changed since v5 and I don't think it will change in the future.To summarize:
RtlProvider
from System to private-theming in v5 and next branch (still reexportRtlProvider
from System), then do the latest release.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 This is the right observation. If
@mui/system
creates a context that's shared between multiple packages, all these packages must resolve their import to the exact same installed dependency. Same version is not even enough, it may be twice installed with the same version.I think so, yes. For
@mui/material
we solve the problem by declaring a peer dependency. I believe it makes sense to do the same for@mui/system
. A peer dependency is saying "I want to use this dependency, but I want to use the version that's already installed by the user" which is part of the behavior we're after. I don't believe there is any way to 100% guarantee we will be receiving the exact transitive dependency of a peer dependency.I don't think that will be necessary to solve the problem here. It can be the decider for which version of
@mui/system
is used.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, this is the issue, adding @mui/system as a peer dependency makes sense. It doesn't makes sense to move the RtlProvider to @mui/private-theming, as this package is aim to share the context between JSS and Emotion. Moving the context is not a solution, resolving to the same @mui/system instance is, so peer dependency is the only solution I see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 one step closer to fix mui/material-ui#40594. We should treat our styling engine, like Shadcn experiences using Tailwind CSS. It's a dependency they are aware of.
Ideally, we would fix mui/material-ui#43443 though. I don't get why MUI System needs a singleton.
As for how this fits with Pigment CSS, regardless of the path we go with, we will need one dependency. The two possible directions:
Now MUI X should be copying the lab, so we should match with https://github.com/mui/material-ui/blob/71a7ff1355e8b6df873dd8440c5a13ae25987ef4/packages/mui-lab/package.json#L45.