-
-
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
Bundle size is way too big #7304
Comments
Are the stats coming from the production build? The documentation of the propTypes is pretty large in dev mode. |
Dev, lets see whats in production. |
Potentially something is still importing the entire lib. I checked my code, I am def. only importing specific files. |
I can't see the Dialog, nor the Avatar being imported. |
Hmm, I am not using Paper for e.g. but probably its a hardcoded dependency of some other components like a Menu or something. I am using List, ListItem, Button, Divider, LinearProgress, Chip, IconButton, Input, Menu, Form, MuiThemeProvider. |
Its quite a number of components, but still, 115kb minified ... React-DOM is 110kb for e.g. React 15kb. |
For e.g. that lodash dependency 60kb, is it really worth it? |
I have something pretty close to you: First finding
We use very few functions of lodash, I'm surprised that we depend on 60 kB of it! |
Then its either the core or not specific imports. |
Btw. why is lodash not in your stats? Probably because the same version is used in the project globally. I am still on lodash 3 globally, thats why it shows me the cost of lodash within material-ui scope. |
Just started optimizing though. |
Wow, I can't even see Material-UI in your bundle. You can start with supertest and all the moment locales :happy:. Also, I have only share the common.js of my app. I have also many more chunk for each page. |
You can))) second column at the bottom. Yes, moment locales and other monsters are on my kill list. |
I'm gonna address the lodash.isEqual shawnmcknight/react-scrollbar-size#2 issue, but I don't know what you could do aside that to improve the bundle size. |
Yeah, I think for material-ui is worth considering removing lodash if its trivial things and review all imports to make sure nothing unneeded is imported. |
Oh, we might have another lodash function messing the bundle size. I'm gonna look into that. |
Oh and a last one, we should split the colors file. |
Here we are #7306. That should help, a lot. |
@kof @oliviertassinari I'm facing this exact problem. I'm importing components like |
I believe there could still be some issues with components importing too much. I've got a bunch of components in my output bundle that don't seem to be in any way related to the components I've imported. For reference, here are all import statements from
If you have ideas how to investigate what actually imports Input, Modal, Form, Select etc, I'd love to get some pointers. |
@maciej-gurban All the extra imports come from |
@oliviertassinari Thanks for a quick reply and the explanation! For now I've changed all my imports to point directly to the files they import, so instead of
I'm doing
This removed all the unnecessary modules from my bundle. Big props for creating those standalone modules. |
what app are u using guys? those squares that indicates the size |
Despite the fact that I am importing specific components only and those are maybe 5. I see in my bundle analyzer this huge dependency. Lets find out why that is so and what can we do about it. Also 60kb of lodash inside sounds like an overkill.
The text was updated successfully, but these errors were encountered: