Skip to content

[data grid] Remove filename ignore list from removePropTypesPlugin in Babel config#22727

Open
sai6855 wants to merge 7 commits into
mui:masterfrom
sai6855:data-prop-types
Open

[data grid] Remove filename ignore list from removePropTypesPlugin in Babel config#22727
sai6855 wants to merge 7 commits into
mui:masterfrom
sai6855:data-prop-types

Conversation

@sai6855

@sai6855 sai6855 commented Jun 10, 2026

Copy link
Copy Markdown
Member

While looking at the Babel config, I noticed DataGrid.tsx and DataGridPro.tsx are the only files exempted from babel-plugin-transform-react-remove-prop-types. Every other component has propTypes stripped 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.tsx was 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 propTypes are stripped in production like everywhere else.

Bundle size impact

Bundle Parsed Gzip
@mui/x-data-grid -7.47 KB (-1.81%) -1.82 KB (-1.51%)
@mui/x-data-grid-pro -11.2 KB (-2.08%) -2.53 KB (-1.61%)

@sai6855 sai6855 changed the title [data grid] Remove filename ignore list from removePropTypesPlugin in… [data grid] Remove filename ignore list from removePropTypesPlugin in Babel config Jun 10, 2026
@code-infra-dashboard

code-infra-dashboard Bot commented Jun 10, 2026

Copy link
Copy Markdown

Deploy preview

https://deploy-preview-22727--material-ui-x.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/x-data-grid ▼-7.47KB(-1.81%) ▼-1.82KB(-1.51%)
@mui/x-data-grid-pro ▼-11.2KB(-2.08%) ▼-2.53KB(-1.61%)
@mui/x-data-grid-premium 0B(0.00%) 0B(0.00%)
@mui/x-charts 0B(0.00%) 0B(0.00%)
@mui/x-charts-pro 0B(0.00%) 0B(0.00%)
@mui/x-charts-premium 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers-pro 0B(0.00%) 0B(0.00%)
@mui/x-tree-view 0B(0.00%) 0B(0.00%)
@mui/x-tree-view-pro 0B(0.00%) 0B(0.00%)
@mui/x-license 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@sai6855 sai6855 added performance scope: data grid Changes related to the data grid. plan: Pro Impact at least one Pro user. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. labels Jun 10, 2026
@sai6855 sai6855 requested review from Janpot and removed request for Janpot June 10, 2026 09:16
@sai6855 sai6855 marked this pull request as ready for review June 10, 2026 09:17
Copilot AI review requested due to automatic review settings June 10, 2026 09:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ignoreFilenames configuration that previously exempted DataGrid.tsx and DataGridPro.tsx from 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.

@sai6855 sai6855 requested review from Janpot and brijeshb42 June 10, 2026 09:20
Comment thread babel.config.mjs Outdated
@@ -32,8 +32,6 @@ export default function getBabelConfig(api) {
if (removePropTypesPlugin) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the ignoreFilenames is removed, then I believe the whole if can go since unsafe-wrap is the default

@Janpot

Janpot commented Jun 10, 2026

Copy link
Copy Markdown
Member

🤔 Interestingly enough, it doesn't look like unsafe-wrap is enabled at the moment: https://code-infra-dashboard.onrender.com/diff-package?package1=https://pkg.pr.new/mui/mui-x/@mui/x-data-grid@cfdf803&package2=https://pkg.pr.new/mui/mui-x/@mui/x-data-grid@e3fc22c

@sai6855

sai6855 commented Jun 10, 2026

Copy link
Copy Markdown
Member Author

🤔 Interestingly enough, it doesn't look like unsafe-wrap is enabled at the moment: https://code-infra-dashboard.onrender.com/diff-package?package1=https://pkg.pr.new/mui/mui-x/@mui/x-data-grid@cfdf803&package2=https://pkg.pr.new/mui/mui-x/@mui/x-data-grid@e3fc22c

DataGrid.js

I built datagrid.js from e3fc22c commit, it looks like in prod env, prop-types are stripped. Check line 833, it says void 0 for prod env

Are you expecting the propTypes to be removed entirely? Just Want to make sure we're comparing the same thing.

@Janpot

Janpot commented Jun 10, 2026

Copy link
Copy Markdown
Member

No, when there's unsafe-wrap configured I expect it to be defined as

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

@sai6855

sai6855 commented Jun 10, 2026

Copy link
Copy Markdown
Member Author

But given that it seems to generate the latter, I guess this PR would be ok

Got it

@Janpot Janpot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok for me if ok for @mui/grid

@sai6855 sai6855 requested review from arminmeh and cherniavskii June 11, 2026 08:20
@sai6855 sai6855 requested a review from flaviendelangle June 11, 2026 08:24
@sai6855

sai6855 commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

Also opened follow-up PR which will strip proptype from render* function #22750, this can be reviewed once current PR is reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance plan: Pro Impact at least one Pro user. scope: data grid Changes related to the data grid. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants