Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Everything goes into dependencies? #6180

Closed
Rolandisimo opened this issue Jan 11, 2019 · 3 comments
Closed

Everything goes into dependencies? #6180

Rolandisimo opened this issue Jan 11, 2019 · 3 comments

Comments

@Rolandisimo
Copy link

Using Typescript for quite a while now I was surprised that create-react-app guide for adding types says that you have to execute the following command:
yarn add typescript @types/node @types/react @types/react-dom @types/jest.

In other words add dependencies that are being used only in development to the dependencies that are supposed to end up in the final build files. (At least that's how I understood the difference between dev and non-dev dependencies)

From docs.npmjs.com about dependencies:

Please do not put test harnesses or transpilers in your dependencies object. See devDependencies, below.

My question is:
Why typescript, node-sass, types and such (seems that all install examples on the website are installing stuff to the dependencies) are not installed in devDependencies i.e. --dev?

P.S. I did read this discussion which seemed somewhat related, but still had this question in mind and wanted someone to make this clear once and for all.

@gaearon
Copy link
Contributor

gaearon commented Jan 11, 2019

It doesn't matter in practice. Put them wherever you like. :-)

@gaearon gaearon closed this as completed Jan 11, 2019
@gaearon
Copy link
Contributor

gaearon commented Jan 11, 2019

The distinction is meaningful for Node apps because they actually are deployed as runtime. So you might not want to deploy development dependencies.

In case of CRA, the end result is a static bundle. So in a sense all dependencies are "development dependencies", even React or libraries you use. They're used only at the build time.

But putting everything into build dependencies can break some deployment scripts that do the initial build on the server. So it's easier to put everything into regular dependencies instead.

@Rolandisimo
Copy link
Author

@gaearon Thanks. Cleared my doubts now. :)

@lock lock bot locked and limited conversation to collaborators Jan 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants