question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

babel-plugin-emotion not working after upgrading to 10

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
ferdabercommented, Jan 19, 2019

@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

1reaction
aaronjensencommented, Dec 28, 2018

afaict, @babel/plugin-transform-react-inline-elements is incompatible with emotion 10.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found