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.

v10 or @emotion/core doesn't run without babel-plugin-transform-inline-environment-variables

See original GitHub issue
  • emotion version: “@emotion/core”: “^10.0.5”
  • react version: ^16.7.0-alpha.2

Relevant code:

import React from "react";

const Login = () => {
  return (
    <section>
      <span
        css={{
          color: "blue"
        }}
      >
        Login
      </span>
    </section>
  );
};

export default Login;

What you did: I followed the documentation and installed emotion and the css prop babel plugin. I then configured .babelrc also as mentioned in documentation. FYI., I am using parcel.js.

  1. npm i --save @emotion/core
  2. npm i -D @emotion/babel-preset-css-prop
  3. .babelrc:
"presets": [
  [
    "@emotion/babel-preset-css-prop",
    {
      "autoLabel": true,
      "labelFormat": "[local]",
      "useBuiltIns": false,
      "throwIfNamespace": true,
      "sourceMap": false
    }
  ]
]

What happened: I get the following error in browser console when I navigate to the login page: process is not defined

Reproduction: What you did section pretty much captures reproduction steps.

Problem description: Looks like v10 needs an explicit installation of babel-plugin-transform-inline-environment-variables which was not needed in previous versions.

Suggested solution: Bundle babel-plugin-transform-inline-environment-variables in babel-plugin-emotion

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

35reactions
louiscentercommented, Jan 1, 2019

@karol-majewski I had the same issue too. The general feeling I got was that babel-preset-css-prop doesn’t play ball with parcel right now, so I looked into the preset’s source code and adapted it to a fresh .babelrc which I’m now using instead.

{
  "plugins": [
    [
      "transform-inline-environment-variables"
    ],
    [
      "babel-plugin-jsx-pragmatic",
      {"export": "jsx", "module": "@emotion/core", "import": "___EmotionJSX"}
    ],
    [
      "@babel/plugin-transform-react-jsx",
      {"pragma": "___EmotionJSX", "pragmaFrag": "React.Fragment"}
    ],
    [
      "emotion"
    ]
  ]
}
10reactions
karol-majewskicommented, Jan 1, 2019

For anyone interested: adding "transform-inline-environment-variables" in the beginning of the list of plugins in .babelrc takes care of the process is not defined error.

However, the @emotion/babel-preset-css-prop preset is still not applying the pragma for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cypress v10 Environment Variables - Gleb Bahmutov
Cypress tests have two different sets of values: the config values and the user values. The config values are controlling the test runner ......
Read more >
Emotion 11
Emotion 11 is a slight evolution over the Emotion 10. It focuses mainly on the developer experience, TS types improvements, switches internals to...
Read more >
Why you shouldn't use @emotion/core - Colin McDonnell
Emotion is my favorite CSS-in-JS library. It's easy to define style classes — both inline or in separate files. You can powerfully compose ......
Read more >
Module not found: Can't resolve '@emotion/react'
I had a similar issue and I resolved it by calling: npm install @emotion/react. or yarn add @emotion/react.
Read more >
@emotion/react | Yarn - Package Manager
The css prop doesn't work via the babel plugin. jsx can be manually imported from @emotion/core (which can be automated with eslint-plugin-emotion) or...
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