-
-
Notifications
You must be signed in to change notification settings - Fork 32.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
[codemod][base] Write a migration script for removal of component
prop from components
#36831
Conversation
Netlify deploy previewhttps://deploy-preview-36831--material-ui.netlify.app/ Bundle size report |
245c47e
to
79e1c1f
Compare
const transformed = root.findJSXElements().forEach((elementPath) => { | ||
// Process only unstyled components | ||
if ( | ||
!elementPath.node.openingElement.name.name.endsWith('Unstyled') || |
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.
This contradicts with the other codemod for removing this suffix, can be instead change the logic to look for imports from @mui/base?
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.
addressed: 3f88c6c
@@ -0,0 +1,25 @@ | |||
// @ts-nocheck | |||
<Input component={CustomRoot} />; |
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.
We should not depend on the name of the component. It would be best to depend on the import.
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.
Can you elaborate? If you are talking about filtering base components, I changed the logic so we filter base components based on import statements.
It's great that the changes are valid now as well, we don't have to sync the codemod with the changes we do per component. |
packages/mui-codemod/src/v5.0.0/base-remove-component-prop.test/actual.tsx
Outdated
Show resolved
Hide resolved
Signed-off-by: Marija Najdova <mnajdova@gmail.com>
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.
Looks good, let's merge!
Added the new codemod to README. Will merge once all CI tests pass. |
We can test in a separate PR to run the codemod in the docs (for e.g. to update all examples), as the result of the codemod is a valid API even now. Would you like to create a PR for it @hbjORbj? |
Yes, sure :) |
Before
After
Breaking Changes
component
prop. The value passed tocomponent
must be transferred intoslots.root
.You can use this codemod to help with the migration.