mui / mui-x

MUI X: Build complex and data-rich applications using a growing list of advanced React components, like the Data Grid, Date and Time Pickers, Charts, and more!
https://mui.com/x/
4.52k stars 1.31k forks source link

[core] Compress throw new Error() to save bundle size #14618

Open oliviertassinari opened 1 month ago

oliviertassinari commented 1 month ago

Summary

Today, MUI X throws errors in plain strings:

https://github.com/mui/mui-x/blob/dd4447c5d26e578def9a560df8b2bbda2a3ca317/packages/x-tree-view/src/internals/plugins/useTreeViewItems/useTreeViewItems.tsx#L36-L43

those add bundle size to end-users

Examples

We should be able to encode them with a key and only bundle this. See https://github.com/mui/material-ui/pull/21214 for prior art on Material UI.

Motivation

No response

Search keywords: -

michelengelen commented 1 month ago

added to the board

flaviendelangle commented 1 month ago

@michelengelen This is not a tree view topic, it's general to X and probably more a core-infra topic.

michelengelen commented 1 month ago

Thanks for pointing that out @flaviendelangle ... moved it out of the board! I'll assign this to me so we don't lose track of it!

flaviendelangle commented 1 month ago

And I suspect that Toolpad / Base UI / Pigment CSS could also benefit from this. Adding it to the code infra board could be a good approach to make sure we build something re-usable throughout all our repos.

cc @Janpot

oliviertassinari commented 1 month ago

Base UI also has a few of those https://github.com/mui/base-ui/blob/1ab27b0510e0ba19157597f17642022a6208ae09/packages/mui-base/src/Slider/Root/SliderProvider.tsx#L21. It's not super important for MUI X, I mean, there are likely other ways to save bundle size to go after first.

Top-level issue created: https://github.com/mui/mui-public/issues/204.