-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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
[TextField] Optimize imports so that unneeded components are not bundled. #9262
Comments
@Graham42 Please refer to the linked issue for an explanation. |
Can this component not be refactored to not pull in |
For additional context. This has an impact of 84 KB of unneeded extra code in my bundle because I'm not using the |
Go for it! 😉 (I'll admit it does seem a bit topsy-turvy at first glance, but given its provinance, I have to assume it was done this way for good reason. ) Edit: spelling. |
I can see from the original issue and pull request that the discussion centered around the component API and usability with makes sense. However app bundle size didn't come up. Please reopen this issue as it has not been resolved. |
Done. I understand your concern, so lets put it out there for feedback. Edit: I used the "performance" label as a proxy for bundle-size, as we don't seem to have anything more appropriate. |
I don't think there is anything more we can do about it. You have different solutions available:
|
@oliviertassinari Just trying to make sure I understand your response: "import directly the component you need." Does that mean I can work around this particular issue? I'm also seeing the redundant
Is there anything I can do differently to avoid this, or do we just need wait until tree-shaking and/or |
@JulesAU What I mean is that the TextField is a helper to simplify the usage of the underlying components. If you want to save some bundle size. It's 100% fine to write your own TextField component without the Select import. https://material-ui.com/demos/text-fields/#components |
Ahh of course... Thanks for the tip! |
Expected Behavior
When using just a couple
TextField
s and aButton
(ie. a login page) and using the babel-plugin-direct-import module, I would expect that only theTextField
andButton
components should be bundled in the ouput.Current Behavior
Many other components including
List
,Menu
, andPopover
get included in the bundle.Steps to Reproduce (for bugs)
I have created a sample project that just uses a TextField.
git clone https://github.com/Graham42/bug-babel-direct-import-material-ui-next
npm install
Context
I'm trying to minimize the bundle size of what needs to be delivered for my login page.
Your Environment
The text was updated successfully, but these errors were encountered: