Skip to content
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

[base] Codemod for hook directory migration #36295

Merged
merged 7 commits into from
Feb 28, 2023

Conversation

hbjORbj
Copy link
Member

@hbjORbj hbjORbj commented Feb 22, 2023

Follow-up on #36235 (review)

@hbjORbj hbjORbj self-assigned this Feb 22, 2023
@hbjORbj hbjORbj added package: codemod Specific to @mui/codemod package: base-ui Specific to @mui/base labels Feb 22, 2023
@hbjORbj hbjORbj added this to the MUI Base stable release milestone Feb 22, 2023
@mui-bot
Copy link

mui-bot commented Feb 22, 2023

Netlify deploy preview

https://deploy-preview-36295--material-ui.netlify.app/

Bundle size report

No bundle size changes

Generated by 🚫 dangerJS against 4c3572a

@mnajdova
Copy link
Member

Should we wait for this to be merged before releasing? Having this in a release after people already migrated may not be as useful as having it in the same release. Can you please include a Breaking change description in #36235 so that people know how the migration should look like?

@michaldudak
Copy link
Member

I've found one case where it doesn't produce a valid output (but it should be pretty uncommon):

import { useSwitch as useBaseSwitch } from '@mui/base/SwitchUnstyled';

should transform to

import useBaseSwitch from '@mui/base/useSwitch';

but instead produces

import useSwitch from '@mui/base/useSwitch'

@hbjORbj
Copy link
Member Author

hbjORbj commented Feb 27, 2023

Can you please include a Breaking change description in #36235 so that people know how the migration should look like?

@mnajdova Sure! I just updated it properly!

@hbjORbj
Copy link
Member Author

hbjORbj commented Feb 27, 2023

@michaldudak Thanks! I addressed your comment.

@hbjORbj
Copy link
Member Author

hbjORbj commented Feb 27, 2023

@michaldudak Thanks! I addressed your comment here and added the test here.

Copy link
Member

@michaldudak michaldudak left a comment

Choose a reason for hiding this comment

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

I tried some other scenarios and couldn't spot any more issues.

return sourceVal.startsWith('@mui/base/') && sourceVal.match('Unstyled');
}) // Process only Base components
.forEach((path) => {
// scenario 1: `@mui/base/<Component>Unstyled/use<Component>`
Copy link
Member

Choose a reason for hiding this comment

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

I don't think that this import was even supported at all. But let's keep it just in case 🤷

@hbjORbj
Copy link
Member Author

hbjORbj commented Feb 27, 2023

@mnajdova Addressed your comments!

@hbjORbj hbjORbj merged commit 661969b into mui:master Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: base-ui Specific to @mui/base package: codemod Specific to @mui/codemod
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants