Why are typescript and various @types packages installed as dependencies instead of devDependencies? #9421
-
More of a question than help needed. I just made a brand new app with the typescript template. I see the following in package.json: "dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"@types/jest": "^24.9.1",
"@types/node": "^12.12.53",
"@types/react": "^16.9.44",
"@types/react-dom": "^16.9.8",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1",
"typescript": "^3.7.5"
}, with nothing in |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Nothing is actually needed to run the app after building it. React and ReactDOM, along with all other dependencies and your code are all included in the compiled bundle. Since the app has no runtime dependencies it doesn't matter if you list dependencies under The reason we chose to use When people submit PRs to "fix" this we usually direct them to this comment: #6180 (comment). |
Beta Was this translation helpful? Give feedback.
-
Cool. Just to understand, does this mean that webpack is going to determine at transpile time what the runtime dependencies are and include them in the bundle? Therefore, the distinction between "dependencies" and "devDependencies" doesn't matter either way? If that's true, does that actually hold true to webpack when used outside of create-react-app? Thank you! |
Beta Was this translation helpful? Give feedback.
Nothing is actually needed to run the app after building it. React and ReactDOM, along with all other dependencies and your code are all included in the compiled bundle. Since the app has no runtime dependencies it doesn't matter if you list dependencies under
dependencies
ordevDependencies
.The reason we chose to use
dependencies
is because certain platforms like Heroku will only installdependencies
when they build your app (this used to be true, I'm not sure if it still is).When people submit PRs to "fix" this we usually direct them to this comment: #6180 (comment).