In your package.json
you have dependencies
and devDependencies
.
{
"devDependencies": {
"webpack": "^4.42.1"
},
"dependencies": {
"react": "^16.13.1"
}
}
I understand that:
dependencies
are deps that your app needs to rundevDependencies
are deps that you only need during development
But, why do they need to be split up like that? What are the benefits?
What happens if I do this?
{
"dependencies": {
"react": "^16.13.1",
"webpack": "^4.42.1"
}
}
Are there any performance hits? Would splitting up the deps only matter if I wanted to publish a module?
This question has nothing to do with: What's the difference between dependencies, devDependencies and peerDependencies in npm package.json file?
That question is asking what dependencies
and devDependencies
are. I clearly stated what they are above.
This question is about why you would want to split deps like this at all. It seems like some people build their app in their prod server. I usually build offline and just ship the index.html
and main.js
artifacts. So some of these points don't apply to my current situation.
Also, after a little more testing, it kinda seems like your devDependencies
don't actually end up in your main.js
bundle file. At least in the way I have my project setup, I didn't see any size difference between splitting my deps and having them all under dependencies
. And because I just ship the build artifact, this doesn't affect my production experience at all.