[data grid] Remove filename ignore list from removePropTypesPlugin in Babel config#22727
[data grid] Remove filename ignore list from removePropTypesPlugin in Babel config#22727sai6855 wants to merge 7 commits into
Conversation
Deploy previewhttps://deploy-preview-22727--material-ui-x.netlify.app/ Bundle size
Check out the code infra dashboard for more information about this PR. |
There was a problem hiding this comment.
Pull request overview
This PR removes the filename-based exemption for babel-plugin-transform-react-remove-prop-types so that DataGrid.tsx and DataGridPro.tsx (and, by extension, all grid tiers) have propTypes stripped from production builds consistently, reducing consumer bundle size.
Changes:
- Removed
ignoreFilenamesconfiguration that previously exemptedDataGrid.tsxandDataGridPro.tsxfrom prop-types removal. - Kept the plugin configured with
mode: 'unsafe-wrap'when present, but no longer special-cases specific grid entrypoints.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -32,8 +32,6 @@ export default function getBabelConfig(api) { | |||
| if (removePropTypesPlugin) { | |||
There was a problem hiding this comment.
If the ignoreFilenames is removed, then I believe the whole if can go since unsafe-wrap is the default
|
🤔 Interestingly enough, it doesn't look like |
I built datagrid.js from e3fc22c commit, it looks like in Are you expecting the propTypes to be removed entirely? Just Want to make sure we're comparing the same thing. |
|
No, when there's if (process.env.NODE_ENV !== 'production') {
Compoent.propTypes = { ... }
}and not Compoent.propTypes = process.env.NODE_ENV === 'production' ? undefined : { ... }But given that it seems to generate the latter, I guess this PR would be ok |
Got it |
|
Also opened follow-up PR which will strip proptype from |
While looking at the Babel config, I noticed
DataGrid.tsxandDataGridPro.tsxare the only files exempted frombabel-plugin-transform-react-remove-prop-types. Every other component haspropTypesstripped in production, but these two keep theirs.The exemption was copied from MUI Core in 2022 (PR https://github.com/mui/mui-x/pull/3965/changes#diff-09c56b2bf95de2a608a36afef3b6893146a959d6739be0a154dc9c9f02d80f24) and appears to have never been revisited. Notably, it predates the Premium package, and
DataGridPremium.tsxwas never added, so the three grid tiers currently behave differently without any documented reason.This PR removes the exemption so all grid packages behave consistently and
propTypesare stripped in production like everywhere else.Bundle size impact
@mui/x-data-grid@mui/x-data-grid-pro