Emotion: babel-plugin-emotion can be installed as dev dependency

Created on 7 Jul 2018  ยท  8Comments  ยท  Source: emotion-js/emotion

I was checking docs at https://emotion.sh/docs/install#with-babel-plugin-emotion & I think it should be installed as a dev dependency, correct me if I am wrong but I think it is not needed to be shipped in production

Most helpful comment

Im pretty sure it should be a dev dependancy - as you should be babel-ing at build time
This setup seems to work for me fine also

All 8 comments

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

Bad bot

I have the same question actually - one of the docs are incorrect?

Yes

Im pretty sure it should be a dev dependancy - as you should be babel-ing at build time
This setup seems to work for me fine also

The babel-plugin-emotion plugin should be installed as "devDependencies" rather than "dependencies", or it will introduce a conflict of multiple @babel/types versions especially when running with babel-eslint:

$ npm ls @babel/types
โ”œโ”€โ”ฌ [email protected]
โ”‚ โ”œโ”€โ”ฌ @babel/[email protected]
โ”‚ โ”‚ โ”œโ”€โ”ฌ @babel/[email protected]
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ @babel/[email protected]
โ”‚ โ”‚ โ”œโ”€โ”ฌ @babel/[email protected]
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”ฌ @babel/[email protected]
โ”‚ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ @babel/[email protected]
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”ฌ @babel/[email protected]
โ”‚ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ @babel/[email protected]
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ @babel/[email protected]
โ”‚ โ”‚ โ”œโ”€โ”ฌ @babel/[email protected]
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ @babel/[email protected]
โ”‚ โ”‚ โ””โ”€โ”€ @babel/[email protected]
โ”‚ โ””โ”€โ”€ @babel/[email protected]
โ””โ”€โ”ฌ [email protected]
  โ””โ”€โ”ฌ [email protected]
    โ””โ”€โ”ฌ [email protected]
      โ””โ”€โ”ฌ @babel/[email protected]
        โ””โ”€โ”€ @babel/[email protected]

$ npm ls @babel/traverse
โ””โ”€โ”ฌ [email protected]
  โ””โ”€โ”€ @babel/[email protected]

@cheton maybe this isn't really a problem? Shouldn't we resolve those issues then?

My two cents are that, if you think of your library being pulled into another project, only the dependencies will be pulled, now depending on how you bundled, if you're providing source, then babel-plugin-emotion needs to be in the dependencies so the consuming application knows to apply that plugin, as the .babelrc gets gobbled up recursively _AFAIK_. If you're providing a built out artefact, then, semantically it'd belong in the devDependencies, as it really isn't needed.

I guess all that matters is how you're bundling the library. If it's not a lib at all, and merely an app that gets deployed. Then put all that "at-built-time" stuff in devDependencies, that way you know exactly what dependencies are required to make the app run, and what deps are required to make the app build.

Tl;DR: The docs should state to install it as a dev dependency.
Without generalising too much, but a large portion of the readers will be building apps with it, and therefore it makes sense to be a dev dep. For those building libraries, they'd probably already know to make it a "prod" dependency.

docs I found said to install as dev

https://github.com/emotion-js/emotion/tree/master/packages/babel-plugin-emotion#installation

which is conflicting docs with the link you posted. I believe you're correct that its a dev dependency, and the emotion website should be updated.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kentcdodds picture kentcdodds  ยท  3Comments

mattfysh picture mattfysh  ยท  3Comments

MrFungusEli picture MrFungusEli  ยท  3Comments

Zn4rK picture Zn4rK  ยท  3Comments

rockmandash picture rockmandash  ยท  3Comments