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
[docs] Update minimizing-bundle-size.md #7169
Conversation
kazazor
commented
Jun 17, 2017
- PR has tests / docs demo, and is linted.
Hey, thanks for submitting that PR! We have an open issue for that point #5625. |
Any babel plugin (including babel-plugin-material-ui) should be a short term workaround, tree shaking should be a solution. And it works. It disables imports and makes components unused, but uglifyjs doesn't count them as dead code. Mostly it's because of Try to uglify this code (https://skalman.github.io/UglifyJS-online/) var Component = (function() {
// Unused component without any statics.
function Foo () {}
// Unused component with prop types.
function Bar() {}
Bar.propTypes = { children: PropTypes.node }
// Used component.
function Baz() {}
return Baz;
})(); See this issue babel/babel#5632 for more details. |
I agree tree shaking is the right solution looking forward. But this Doc doesn't say anything about it. For example tree shaking does work in Rollup.js I will edit the page to include also tree shaking information |
@umidbekkarimov - I committed a new proposal that IMO gives the users the most information about the different options to optimize the bundle. Please review it and let me know what you think :) |
@kazazor thank you for your time 👍. I have no problems with this. But as @oliviertassinari mentioned, it's not the only one solution, also another babel plugins could be mentioned.
But I didn't use them, so I can't help you any further 😓. P.S. just checked micro example in rollup and it's surprisingly works. |
Oh, just notice that it's for |
I actually used the two plugins you mentioned, and it works :) Please let me double check |
@kazazor I much prefer the new version :).
@umidbekkarimov Right, thanks for linking the two other plugins!
[
{
"libraryName": "antd",
"libraryDirectory": "lib",
"style": true
},
{
"libraryName": "material-ui",
"libraryDirectory": "components",
"camel2DashComponentName": false
}
]
|
Just published Had to replace regexp lookup with babylon parser (https://github.com/umidbekkarimov/babel-plugin-material-ui/blob/next/src/utils.js#L34). So basically it works now (all tests passed, test PRs are welcomed), but without support of P.S. maybe I should add few changes and make it index-file shape agnostic, but it would be hard coded smarter analogue of |
@oliviertassinari so I didn't understand if you want me to also add lodash plugin? :) Also regarding the import plugin, isn't that what the material-ui plugin brings you..? Why should we use both? |
@umidbekkarimov I'm happy to hear that
@kazazor I think that it would be good to document the three babel alternatives available as they have different tradeoffs. They are not supposed to be used at the same time, people will have to pick one if that's something they are interested in. I would rather let the community decide what's the best solution for them. |
@kazazor I'm merging, thanks for the update. |