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

Reason behind the division of devDependencies and dependencies? #1764

Closed
FezVrasta opened this issue Mar 8, 2017 · 6 comments
Closed

Reason behind the division of devDependencies and dependencies? #1764

FezVrasta opened this issue Mar 8, 2017 · 6 comments

Comments

@FezVrasta
Copy link
Contributor

Hi, I searched in the past issues but I couldn't find anything related.

I'm wondering why do you leave in dependencies only react and react-dom and all the other dependencies are under devDependencies?

I studied a lot about the distinction between the two lists, and to me, everything should go under devDependencies because none of them will be used directly by the compiled app, because Webpack will bundle them together into a single pack, meaning that if I do npm i my-app I could directly use it without having to install any dependency at all because the bundle would be already shipped in the npm bundle.

I know it's a bit abstract because the purpose of create-react-app is not to publish apps to npm, but it's the only way I can reason about dependencies vs devDependencies.

May you shed some light on the argument please?

@silvenon
Copy link

silvenon commented Mar 8, 2017

In my experience devDependencies should contain stuff like testing frameworks, assertion libraries etc. Build tools, frontend frameworks etc. should all go in dependencies. The reason for this is so you can run yarn --production in an automated build step, which only installs dependencies needed to build the app, making installation somewhat faster.

But that's just my two cents.

@FezVrasta
Copy link
Contributor Author

FezVrasta commented Mar 8, 2017

Yes this is another approach and I'm okay with it, but create-react-app makes use of whatwg-fetch, object-assign and others which, following your idea, should go in dependencies because they will be directly used by the app.

Same for webpack and others, in your specific case.

@gaearon
Copy link
Contributor

gaearon commented Mar 8, 2017

There’s no real difference because the app has a build step, and produces a static bundle. So Node meaning doesn’t quite apply here.

I’m trying to use dependencies for libraries that end up in the bundle, and devDependencies for stuff that is related to build tooling. As you noted with polyfills it isn’t such a clear distinction. However, I think it can be helpful to get a sense of what’s needed for the build versus what’s used by the app.

@gaearon gaearon closed this as completed Mar 8, 2017
@FezVrasta
Copy link
Contributor Author

I see, thank you for the answer.

@benknight
Copy link

benknight commented Oct 4, 2017

So what I've gleamed from this is the Node meaning doesn't apply here, and the distinction between devDependencies and dependencies is rather arbitrary. That being the case, I would probably just recommend for simplicity that everything just go under dependencies.

@Aeal
Copy link

Aeal commented Jan 26, 2018

So I have a question. Say that we implemented an express back end to serve our prebuilt application in production, would you still suggest keeping react and react-dom in dependencies or would you move them to devDependencies? Assume the server is NOT referencing react or react-dom.

tkrotoff added a commit to tkrotoff/react-form-with-constraints that referenced this issue May 17, 2018
See Reason behind the division of devDependencies and dependencies? facebook/create-react-app#1764
tkrotoff added a commit to tkrotoff/react-form-with-constraints that referenced this issue May 17, 2018
See Reason behind the division of devDependencies and dependencies? facebook/create-react-app#1764
@lock lock bot locked and limited conversation to collaborators Jan 20, 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

5 participants