Skip to content

[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

Merged

Conversation

oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Feb 16, 2019

moved to #14767.

@oliviertassinari oliviertassinari added package: styles Specific to @mui/styles. Legacy package, @material-ui/styled-engine is taking over in v5. breaking change labels Feb 16, 2019
@oliviertassinari oliviertassinari changed the title [styles] Remove the old styles modules WIP [styles] Remove the old styles modules Feb 16, 2019
@eps1lon eps1lon mentioned this pull request Feb 16, 2019
56 tasks
@oliviertassinari oliviertassinari force-pushed the remove-old-styles-modules branch 3 times, most recently from a4ef194 to 5375f96 Compare February 16, 2019 22:50
@oliviertassinari oliviertassinari self-assigned this Feb 19, 2019
@oliviertassinari oliviertassinari force-pushed the remove-old-styles-modules branch from 5375f96 to be4b7c6 Compare February 22, 2019 17:21
@oliviertassinari oliviertassinari force-pushed the remove-old-styles-modules branch 3 times, most recently from 4d5fe17 to ceb8276 Compare February 27, 2019 15:24
@oliviertassinari oliviertassinari changed the title WIP [styles] Remove the old styles modules [styles] Remove the old styles modules Feb 27, 2019
@oliviertassinari oliviertassinari force-pushed the remove-old-styles-modules branch 9 times, most recently from 77971a7 to a82d8dc Compare February 27, 2019 23:38
eps1lon pushed a commit that referenced this pull request Mar 4, 2019
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.*
@oliviertassinari oliviertassinari force-pushed the remove-old-styles-modules branch 3 times, most recently from fd6b76b to 0fe2fdf Compare March 5, 2019 23:30
@mui-pr-bot
Copy link

mui-pr-bot commented Mar 5, 2019

@material-ui/core: parsed: -2.51% 😍, gzip: +0.12%
@material-ui/lab: parsed: -7.40% 😍, gzip: -1.07% 😍
@material-ui/styles: parsed: +2.57% , gzip: +2.73%

Details of bundle changes.

Comparing: 7a49f80...cea8cb8

bundle parsed diff gzip diff prev parsed current parsed prev gzip current gzip
@material-ui/core -2.51% +0.12% 🔺 371,832 362,506 91,939 92,050
@material-ui/lab -7.40% -1.07% 184,281 170,653 50,584 50,044
@material-ui/styles +2.57% 🔺 +2.73% 🔺 55,687 57,118 15,825 16,257
@material-ui/system -0.12% +0.36% 🔺 17,062 17,041 4,482 4,498
Button -8.35% +1.09% 🔺 99,409 91,106 26,607 26,898
Modal -8.86% +1.69% 🔺 98,984 90,213 26,263 26,707
Paper +Infinity% 🔺 +Infinity% 🔺 0 63,293 0 19,264
Paper.cjs +Infinity% 🔺 +Infinity% 🔺 0 68,801 0 20,153
Popper +Infinity% 🔺 +Infinity% 🔺 0 30,456 0 10,534
colorManipulator 0.00% +0.15% 🔺 3,232 3,232 1,296 1,298
createMuiTheme +Infinity% 🔺 +Infinity% 🔺 0 17,284 0 5,700
docs.landing 0.00% 0.00% 51,891 51,891 11,291 11,291
docs.main -7.81% -6.40% 678,326 625,369 206,184 192,994
useMediaQuery +Infinity% 🔺 +Infinity% 🔺 0 2,486 0 1,050
packages/material-ui/build/umd/material-ui.production.min.js -3.53% +0.16% 🔺 322,466 311,092 85,044 85,183
@material-ui/core/Paper -100.00% -100.00% 76,648 0 19,308 0
@material-ui/core/Paper.esm -100.00% -100.00% 71,599 0 18,783 0
@material-ui/core/Popper -100.00% -100.00% 30,462 0 10,582 0
@material-ui/core/styles/createMuiTheme -100.00% -100.00% 17,286 0 5,717 0
@material-ui/core/useMediaQuery -100.00% -100.00% 2,486 0 1,049 0

Generated by 🚫 dangerJS against cea8cb8

@oliviertassinari oliviertassinari force-pushed the remove-old-styles-modules branch 3 times, most recently from 56e6093 to 2564e45 Compare March 6, 2019 00:39
Copy link
Member

@eps1lon eps1lon left a 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';
Copy link
Member

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';

Copy link
Member Author

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;
Copy link
Member

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.

Copy link
Member Author

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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this for?

Copy link
Member Author

@oliviertassinari oliviertassinari Mar 6, 2019

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.

Copy link
Member

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.

Copy link
Member Author

@oliviertassinari oliviertassinari Mar 6, 2019

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)

withTheme,
WithTheme,
} from './styles';
export { createMuiTheme, Theme, withStyles, WithStyles, withTheme, WithTheme } from './styles';
Copy link
Member

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;
Copy link
Member

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.

Copy link
Member Author

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',
Copy link
Member

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.

Copy link
Member Author

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?

@oliviertassinari oliviertassinari force-pushed the remove-old-styles-modules branch from 1f2791f to cea8cb8 Compare March 6, 2019 12:43
@oliviertassinari oliviertassinari merged commit 22c8147 into mui:next Mar 6, 2019
@oliviertassinari oliviertassinari deleted the remove-old-styles-modules branch March 6, 2019 13:18
@oliviertassinari oliviertassinari removed breaking change package: styles Specific to @mui/styles. Legacy package, @material-ui/styled-engine is taking over in v5. labels Mar 6, 2019
@zannager zannager added the package: styles Specific to @mui/styles. Legacy package, @material-ui/styled-engine is taking over in v5. label Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: styles Specific to @mui/styles. Legacy package, @material-ui/styled-engine is taking over in v5.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants