-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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] Change material-ui/styles folder structure #14868
Conversation
VincentLanglet
commented
Mar 13, 2019
- I have followed (at least) the PR section of the contributing guide.
@@ -2,8 +2,8 @@ import React from 'react'; | |||
import PropTypes from 'prop-types'; | |||
import warning from 'warning'; | |||
import { exactProp } from '@material-ui/utils'; | |||
import ThemeContext from './ThemeContext'; | |||
import useTheme from './useTheme'; | |||
import ThemeContext from '../useTheme/ThemeContext'; |
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 the most controversial change I can find in the pull request. I do prefer hosting ThemeContext in the consumer than in the provider. People might not use the provider, but will always use the consumer. So, why not 👍.
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 had to make a choice. I decided this way.
ThemeProvider was already importing useTheme
But useTheme wasn't importaing ThemeProvider
So I wanted to avoid to create something similar to a circular reference
@material-ui/core: parsed: -0.45% 😍, gzip: -0.40% 😍 Details of bundle changes.Comparing: 2f6a982...23667ff
|
Will have conflict with #14856 |
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.
Webpack didn't pick up the esm build before. Now it does which is why it displays these savings.
It's an issue with the webpack config we use for the snapshots. We have to target the cjs barrel1 which previously pointed directly to the cjs files. Now it points to the sub modules and webpack can work its magic. It can now pick up the package.json for every sub module and chooses the esm files.
The savings for @material-ui/styles
are only virtual. Not quite sure why the other packages display the savings. It's very hard to debug with path imports.
I'm curious to see the impact on this tool https://bundlephobia.com/result?p=@material-ui/styles. @VincentLanglet Well done :) |