Skip to content

[codemod] Add --jsx option to v9.0.0/system-props codemod#48315

Merged
ZeeshanTamboli merged 4 commits into
mui:masterfrom
siriwatknp:fix/codemod-system-props-jsx-option
Apr 21, 2026
Merged

[codemod] Add --jsx option to v9.0.0/system-props codemod#48315
ZeeshanTamboli merged 4 commits into
mui:masterfrom
siriwatknp:fix/codemod-system-props-jsx-option

Conversation

@siriwatknp
Copy link
Copy Markdown
Member

@siriwatknp siriwatknp commented Apr 17, 2026

closes #48269

Summary

The v9.0.0/system-props codemod relies on import detection to identify MUI components. This means it produces 0 changes in projects that use auto-import plugins (e.g. unplugin-auto-import) where components like Box, Typography, etc. are globally available without explicit import statements.

This PR adds a --jsx option that accepts a comma-separated list of JSX element names to treat as MUI components, bypassing import detection:

npx @mui/codemod@latest v9.0.0/system-props src/ -- --jsx=Box,Typography,Stack,Link,Grid,DialogContentText

For Reviewers

The --jsx option is passed as a codemod-specific flag (via --) rather than a global CLI option, following the existing pattern used by --component, --from, --to flags (see codemod.js L221).

In removeSystemProps.js, when options.jsx is provided, the comma-separated names are parsed and added directly to deprecatedElements[] (with elementReplacement for Typography/Link special color handling), before the import scanning phase runs. This means both mechanisms can work together — imports are still scanned normally, and --jsx adds additional targets.

Only names matching the known components list are accepted to avoid accidental transforms on unrelated elements.


@code-infra-dashboard
Copy link
Copy Markdown

code-infra-dashboard Bot commented Apr 17, 2026

Bundle size

Bundle Parsed size Gzip size
@mui/material 0B(0.00%) 0B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Deploy preview


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

@siriwatknp siriwatknp added package: codemod Specific to codemod. 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 Apr 17, 2026
@zannager zannager requested a review from mj12albert April 17, 2026 15:14
Copy link
Copy Markdown
Member

@ZeeshanTamboli ZeeshanTamboli left a comment

Choose a reason for hiding this comment

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

Left two comments. Rest looks good to me!

Comment thread docs/data/material/migration/upgrade-to-v9/upgrade-to-v9.md Outdated
Comment thread packages/mui-codemod/README.md Outdated
@ZeeshanTamboli ZeeshanTamboli changed the title [codemod] Add --jsx option to system-props codemod [codemod] Add --jsx option to v9.0.0/system-props codemod Apr 18, 2026
Co-authored-by: Zeeshan Tamboli <zeeshan.tamboli@gmail.com>
Signed-off-by: Siriwat K <siriwatkunaporn@gmail.com>
@siriwatknp siriwatknp enabled auto-merge (squash) April 20, 2026 02:21
@siriwatknp siriwatknp disabled auto-merge April 20, 2026 02:21
@ZeeshanTamboli
Copy link
Copy Markdown
Member

Looks good with the new change to support arbitrary components.

@ZeeshanTamboli ZeeshanTamboli merged commit 6dc80a6 into mui:master Apr 21, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: codemod Specific to codemod. 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.

[codemod] v9.0.0/system-props codemod does not work with auto-imported components (unplugin-auto-import)

2 participants