Automatically rename legacy emotion imports to new supported emotion versions
Demo repository with Webpack+Babel+React+Emotion11
- Scan all imports, try to rename legacy import from
emotion/react-emotionto@emotion/css - If it used styled, add additional new import
@emotion/styled - If the emotion.css is used within styled, swap with css method from
@emotion/react
- Legacy v9 to v11
- Some things may not be working, please checkout with caution!
- If you're using SSR, It's very recommended to also implement
@emotion/cssSSR integration as well for smoother migration
- If you import a variable from another file, and that variable is used within styled/css tagged template literal, then it's currently impossible to statically analyze and rename the import
$ npm install --save-dev babel-plugin-emotion-rename
{
"plugins": ["babel-plugin-emotion-rename"]
}- Codemod CLI coming soon, so that we can drop runtime transpilation step.
MIT