-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Tree shaking doesnt work properly for mui-x datagrid and datepicker #7332
Comments
Related #5076 In the example repo provided above, switching to dayjs adapter - builds faster than with the datefns adapter. |
Hello @andriijas I've looked at the examples a bit. Ideally, such big ui libraries "must" be separated into their own bundle and lazy loaded in order to improve end user experience (responsiveness), but I'd think that it is the main thing that everyone would reach for when improving app performance. As for |
I agree with @LukasTy Regarding this:
MUI X packages are tree shakeable out of the box. |
I absolutely agree on this, in my teams we did prioritise shipping product over optimal bundle size by opting in to these packages rather than writing our own. But I think we all can agree that in best of worlds you want the benefits of both ways. As seen in the examples we do use similar pattern in real project to have these packages in their own chunks and only loaded by the views that actually provides a datagrid or a datepicker but It would be cool if its possible to make the packages lighter if not using all features of them. / thanks🙏 We will probably look into switching to dayjs as we dont use date-fns a lot. That would save some bandwidth at least :) Thanks everyone. |
So, we can close? It's more a problem with having too much logic, than tree-shaking. I think that one of the most impactful thing we could do is solve #5550 so we can accurately measure progress. |
@oliviertassinari @cherniavskii @LukasTy is it recommended to wrap the whole app with @mui/x-date-pickers/LocalizationProvider or it should only wrap actual DatePicker instances? |
I would recommend to wrap the whole app with a If can be needed if you need to pass some |
Duplicates
Latest version
Steps to reproduce 🕹
Link to live example:
Two examples
https://github.com/andriijas/mui-x-bundle-size/tree/splitChunks
or
https://github.com/andriijas/mui-x-bundle-size/tree/suspense
Steps:
Current behavior 😯
Current behavior adds excessive amount of script, it also increases build speed a lot.
Also look how it adds ALL of date-fns via the adapter, is everything actually used?
Similar issue #18
Expected behavior 🤔
mui-x should be tree shakeable like mui,
Could import like this like in mui help?
instead of
Context 🔦
Without the Datepicker and datagrid demo in Album.tsx:
With the Datepicker and datagrid demo in Album.tsx, the app grows from 245kb to 920kb, and the build speed increases significantly.
Your environment 🌎
npx @mui/envinfo
Order ID 💳 (optional)
No response
The text was updated successfully, but these errors were encountered: