-
-
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
[docs] Improve bundle size option 2 advantage wording #17577
Conversation
No bundle size changes comparing d28f415...90d2c90 |
@ilanbm The Babel plugin on https://material-ui.com/guides/minimizing-bundle-size/#option-2 is meant to provide equal bundling speed. If somebody cares enough to apply a codemod, would it be better to use the Babel plugin instead? |
TL;DR Optimizations should be handled at compile time not manually. It makes more sense to put this into a babel plugin since this can give us the freedom to move things around internally and address that in the babel plugin. Any optimization with a codemod has to be reapplied if the codemod improves/changes. Same applies to new code that you introduce which also needs this codemod applied. We had this stance on the |
@eps1lon the goal here is to have fast imports that don't need extra compilation / tree shaking. |
@oliviertassinari if option 2 has equal bundling speed, then why is it the direct import titled "fast"? |
I'm pretty sure that by doing it during transpilation webpack won't pick up the first bundle. We're implementing naive tree-shaking at the transpiler level. The cost of rewriting an import is negligible. But if you have some benchmarks comparing a babel plugin which rewrites the import with pre-rewritten imports then I would take a look again. Otherwise I'll reiterate that optimizations should almost never be done manually. That's what a compiler is for. |
@ilanbm I would propose that we focus on the documentation. If the page makes you think that option 1 is the fastest, then we don't do a good job with the current wording. It's fast, as much as option 2 with the Babel plugin. I think that we can expand this sentence.
Should we continue the documentation changes in this pull request? |
@oliviertassinari I agree, if they are fast the same way than the docs weren't so clear |
01530b3
to
52408d2
Compare
52408d2
to
be5dc43
Compare
be5dc43
to
cbfe9b3
Compare
@ilanbm I have tried to improve the wording with a new commit. Let us know if it's better of it you have a different suggestion :). |
@oliviertassinari it's way better now, now it is clear. thanks! |
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.
Great re-wording!
docs/src/pages/guides/minimizing-bundle-size/minimizing-bundle-size.md
Outdated
Show resolved
Hide resolved
docs/src/pages/guides/minimizing-bundle-size/minimizing-bundle-size.md
Outdated
Show resolved
Hide resolved
docs/src/pages/guides/minimizing-bundle-size/minimizing-bundle-size.md
Outdated
Show resolved
Hide resolved
docs/src/pages/guides/minimizing-bundle-size/minimizing-bundle-size.md
Outdated
Show resolved
Hide resolved
3fd59da
to
bf1e245
Compare
bf1e245
to
1021e84
Compare
Speed is identical between option 1 and 2.
####fast-imports
Converts all@material-ui/core
top level imports to direct path importson https://material-ui.com/guides/minimizing-bundle-size/ it says that direct path imports are the fastest way. Current existing codemodes don't satisfy the need to rapidly use this fast import option.

screenshot from minimizing-bundle-size doc: