-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add codemod to replace individual package imports with monopackage imports #6471
Conversation
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.
Don't know how you've found this to run on a project with hundreds of files, but you could move a lot of this outside the transform function and only perform once (discovery of all the monopackage exports)
@snowystinger good idea, I'll try to handle that in a follow-up, as well as integrating this: https://github.com/facebook/jscodeshift/blob/main/recipes/retain-first-comment.md |
## API Changes
unknown top level export { type: 'any' } |
Replaces individual package imports with monopackage imports, where possible.
Works for:
@react-spectrum/*
->@adobe/react-spectrum
@react-aria/*
->react-aria
@react-stately/*
->react-stately
By default this will apply to all the above packages, or optionally you can specify which packages to apply this to by passing a comma-separated list to the packages option:
--packages=react-aria,react-stately,react-spectrum
.Run this from a directory where the relevant packages are installed in
node_modules
so it knows which monopackage exports are available to use (since exports may vary by version).npm i -g jscodeshift
jscodeshift -t /path/to/use-monopackages.ts src/
✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project: