babel-plugin-emotion not working after upgrading to 10
See original GitHub issueI upgraded from Emotion 9
to 10
, and it seems like the babel plugin
is now ignored. I’ve pinpointed the issue to the babel plugin
version. If I keep Emotion
at 10
, and just revert the babel plugin
back to 9.2.11
, I will be able to see class labels in development again.
I don’t know how to reproduce this, but when testing different git commits I was definitely able to pinpoint it to just upgrading the babel plugin from 9.2.11 to 10.0.5. I even tried using earlier versions of the 10 plugin (10.0.0 - 10.0.4) to no avail.
Is there any way I can debug it better, to provide you with more info?
Relevent code:
webpack:
{
test: /\.(js|tsx|ts)$/,
exclude: /(node_modules)/,
use: [{
loader: 'babel-loader',
options: { babelrc: true }
},
{
loader: 'ts-loader',
options: {
transpileOnly: process.env.NODE_ENV !== 'production',
getCustomTransformers: () => ({
before: [tsTransformAsyncToMobxFlow()]
})
}
}
]
},
babelrc:
{
"plugins": [
"@babel/plugin-syntax-dynamic-import",
["import", { "libraryName": "antd", "style": true }]
],
"env": {
"langs": {
"plugins": [
"@babel/plugin-transform-modules-commonjs"
]
},
"development": {
"plugins": [
["@babel/plugin-transform-react-display-name"],
["emotion", { "sourceMap": true, "autoLabel": true }]
]
},
"production": {
"comments": false,
"plugins": [
"@babel/plugin-transform-react-constant-elements",
"@babel/plugin-transform-react-inline-elements",
"transform-react-remove-prop-types",
["emotion"]
]
}
}
}
tsconfig:
{
"compilerOptions": {
"pretty": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "./typescript-build",
"suppressImplicitAnyIndexErrors": true,
"moduleResolution": "node",
"jsx": "react",
"module": "esnext",
"noImplicitAny": true,
"preserveConstEnums": true,
"removeComments": true,
"target": "esnext",
"sourceMap": true,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"baseUrl": ".",
"paths": {
"~dpStores/*": ["src/stores/*"],
"~dpTooltip": ["src/shared/components/tooltip.tsx"],
"~dpEmotion": ["src/shared/themes/emotion.tsx"]
}
},
"exclude": [
"node_modules"
],
"plugins": [
{
"name": "tslint-language-service",
"alwaysShowRuleFailuresAsWarnings": false,
"ignoreDefinitionFiles": true
},
{
"name": "typescript-styled-plugin"
},
{ "transform": "ts-transform-async-to-mobx-flow", "type": "config" }
]
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:16 (9 by maintainers)
Top Results From Across the Web
@emotion/babel-plugin - npm
A recommended babel preprocessing plugin for emotion, The Next Generation of CSS-in-JS.. Latest version: 11.10.5, last published: 2 months ...
Read more >Babel Plugin - Emotion
Install. In emotion version 8 and above, installation is optional. In older versions, installation is required. See the installation instructions.
Read more >Emotion 11
Emotion 11 is a slight evolution over the Emotion 10. ... If you encounter build issues after upgrade, try removing any manually specified...
Read more >Upgrade Guide - Next.js
A codemod is available to automatically fix cases where you accidentally used React without importing it. Upgrading from version 9 to 10. There...
Read more >What is the proper way to enable the css prop in Emotion 11 ...
If using the automatic runtime, you should be able to fix the issue by adding ... @emotion/styled && npm i --save-dev @emotion/babel-plugin
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@tkh44 I was able to work around this issue by placing the preset last in the order, because babel’s preset follow a function composition order (last to first): https://babeljs.io/docs/en/presets#preset-ordering
afaict,
@babel/plugin-transform-react-inline-elements
is incompatible with emotion 10.