-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[DataGrid] Reduce bundle size with error messages #12992
[DataGrid] Reduce bundle size with error messages #12992
Conversation
Deploy preview: https://deploy-preview-12992--material-ui-x.netlify.app/ |
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.
I agree these validation errors should not be needed in production 👍
I pushed a new commit, it didn't work, let's see if this is enough. Edit: It seems to be good. Asking for review from Alexandre as it's a follow-up on #11303. |
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.
Thanks!
With component stacks, we should be able to replace propTypes completely 👍🏻
Problem
Open https://mui.com/x/react-data-grid/, see how we load unless code in the JS bundle:
It increases the bundle size reported in https://bundlephobia.com/package/@mui/x-data-grid 🙃.
Solution
The most popular minifiers, esbuild seem to win https://npmtrends.com/esbuild-vs-terser-vs-uglify-js. A quick reproduction: https://esbuild.github.io/try/#YgAwLjIwLjIAeyBtaW5pZnk6IHRydWUsIGJ1bmRsZTogdHJ1ZSB9AABwcm9wVmFsaWRhdGlvbi5qcwBleHBvcnQgY29uc3QgcHJvcFZhbGlkYXRvcnMgPSBbKCkgPT4gJ2Vycm9yIG1lc3NhZ2UnXTsKCmV4cG9ydCBmdW5jdGlvbiB2YWxpZGF0ZVByb3BzKHByb3BzLCB2YWxpZGF0b3JzKSB7CiAgaWYgKHByb2Nlc3MuZW52Lk5PREVfRU5WID09PSAncHJvZHVjdGlvbicpIHsKICAgIHJldHVybjsKICB9CiAgdmFsaWRhdG9ycy5mb3JFYWNoKCh2YWxpZGF0b3IpID0+IHt9KTsKfQBlAERhdGFHcmlkLmpzAGltcG9ydCB7oHZhbGlkYXRlUHJvcHMsIHByb3BWYWxpZGF0b3JzIH0gZnJvbSAnLi9wcm9wVmFsaWRhdGlvbic7CgpleHBvcnQgZGVmYXVsdCBmdW5jdGlvbiBEYXRhR3JpZChwcm9wcykgewogIHZhbGlkYXRlUHJvcHMocHJvcHMsIHByb3BWYWxpZGF0b3JzKTsKICByZXR1cm4gImZvbyI7Cn0
I thought it was because the function isn't treated as pure by default by minifiers, why our Babel transformers add those
/*#__PURE__*/
in https://unpkg.com/browse/@mui/x-data-grid@7.3.2/DataGrid/DataGrid.js. But it doesn't seem to be this. So I went with the simplest solution.Preview: https://deploy-preview-12992--material-ui-x.netlify.app/x/react-data-grid/
Off-topic: I think a reason why we need #5550. It would have been caught when we introduced this regression in #11303.