-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
[styles] Remove the old styles modules #14560
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
[styles] Remove the old styles modules #14560
Conversation
a4ef194
to
5375f96
Compare
5375f96
to
be4b7c6
Compare
4d5fe17
to
ceb8276
Compare
77971a7
to
a82d8dc
Compare
The whole community is using hoist-non-react-statics, let's go for it. We should be able to remove the yarn version lock at some point. *This change is taken from #14560 as an effort not to merge too big pull requests.*
fd6b76b
to
0fe2fdf
Compare
@material-ui/core: parsed: -2.51% 😍, gzip: +0.12% Details of bundle changes.Comparing: 7a49f80...cea8cb8
|
56e6093
to
2564e45
Compare
2564e45
to
08ac17f
Compare
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.
Main objection is about bundle names. Other things are mainly about clarifying the @material-ui/core/styles
vs. @material-ui/styles
difference
@@ -1,8 +1,8 @@ | |||
import React from 'react'; | |||
import PropTypes from 'prop-types'; | |||
import { create } from 'jss'; | |||
import { withStyles, jssPreset } from '@material-ui/core/styles'; | |||
import { StylesProvider } from '@material-ui/styles'; | |||
import { withStyles } from '@material-ui/core/styles'; |
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 thought the old module was removed and we use
- import { withStyles } from '@material-ui/core/styles';
+ import { withStyles } from '@material-ui/styles';
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.
You made me think that I have forgotten the hook demos. I have done the following change:
-import { makeStyles } from '@material-ui/styles';
+import { makeStyles } from '@material-ui/core/styles';
So people can copy & paste the demos directly.
|
||
return (props = {}) => { | ||
const theme = listenToTheme ? React.useContext(ThemeContext) || defaultTheme : defaultTheme; | ||
const theme = (listenToTheme ? useTheme() : null) || defaultTheme; |
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 would go with the pattern suggested from the react issue and call a custom hook unconditionally that was created in the outer scope. That whole statement looks really scary.
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.
Hum 🤔
more.theme = theme; | ||
} | ||
} | ||
|
||
return <Component ref={innerRef || ref} classes={classes} {...more} />; | ||
}); | ||
|
||
if (process.env.NODE_ENV === 'test' && !ponyfillGlobal.disableShallowSupport) { |
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.
What's this for?
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 removes the need for migrating all the tests away from the shallow API. We can consider killing this code branch once we have removed all the shallow tests :). It has a second advantage, it makes the class names deterministic in the test environment. Related to #14358.
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.
it makes the class names deterministic in the test environment
That is a lot of redundant code for behavior that is only required for a single testing pattern that is already solvable. Emotion and styled-components agree with me here. I hope this gets removed once we figure out shallow testing.
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.
Yes, I think that this whole code branch should get removed. Now the tradeoff was:
remove install() step > this extra logic, (> as more important)
packages/material-ui/src/index.d.ts
Outdated
withTheme, | ||
WithTheme, | ||
} from './styles'; | ||
export { createMuiTheme, Theme, withStyles, WithStyles, withTheme, WithTheme } from './styles'; |
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 doesn't match packages/material-ui/src/index.js
} | ||
|
||
export default ponyfillGlobal.__MUI_STYLES__.MuiThemeProvider; | ||
export default ThemeProvider; |
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.
If it still exists we should include the types.
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.
It's only here until I figure out how to handle the CDN demo.
@@ -71,14 +71,14 @@ async function getSizeLimitBundles() { | |||
}, | |||
{ | |||
// vs https://bundlephobia.com/result?p=react-popper | |||
name: '@material-ui/core/Popper', | |||
name: 'Popper', |
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.
diffs are tracked via name
. Should've named this id
instead to make its purpose clear.
We can introduce a human label
in another PR.
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.
We shouldn't have any collision (or few exceptions) between the modules we are exporting. How is this an issue?
1f2791f
to
cea8cb8
Compare
moved to #14767.