emotion icon indicating copy to clipboard operation
emotion copied to clipboard

babel-plugin-emotion should not be a runtime dependency

Open puncha opened this issue 4 years ago • 3 comments

Current behavior:

For the installed emotion package, babel-plugin-emotion is a dev-dependencies, but it is in dependencies section. I have to install babel-plugin-emotion in my production environment.

{
  "name": "emotion",
  "version": "10.0.6",
  "dependencies": {
    "babel-plugin-emotion": "^10.0.6",
    "create-emotion": "^10.0.6"
  },
  "devDependencies": {
    "@emotion/stylis": "0.8.3",
    "babel-plugin-transform-define": "^1.3.0",
    "dtslint": "^0.3.0",
    "stylis": "3.5.4",
    "stylis-rule-sheet": "^0.0.10"
  }
}

To reproduce:

  1. install this package
  2. open node_modules/emotion/package.json

Expected behavior:

babel-plugin-emotion should not be part of dependencies.

Environment information:

  • react version:
  • @emotion/react version:

puncha avatar May 08 '21 03:05 puncha

Current emotion veriosn is v11 and emotion package be deprecated.

// https://cdn.jsdelivr.net/npm/[email protected]/dist/emotion.esm.js

throw new Error("The `emotion` package has been renamed to `@emotion/css`. 
Please import it like this `import { css } from '@emotion/css'`.");

Please use emotion v11 and you will not encounter this issue.

iChenLei avatar May 08 '21 10:05 iChenLei

@puncha that is because we support emotion/macro in v10 (and @emotion/css/macro in v11). For that, you need babel-plugin-emotion. I don't believe that it's a big deal to put that in dependencies as it simplifies the installation instructions for users of the /macro variant.

Andarist avatar May 10 '21 07:05 Andarist

I need to have a list of all dependencies in the project for analysis. It is very frustrating to have source-map, cosmiconfig in dependencies (because they are dependencies for @emotion/babel-plugin.

Looks like not all use @emotion/babel-plugin, why not install it separately?

Semigradsky avatar Oct 30 '23 10:10 Semigradsky