1

I just boostrapped a React project with typescript with the following command:

npx create-react-app frontend --template typescript

enter image description here

I am surprised to find tyepscript but also @testing and @types libraries into my dependencies and not my devDependencies. Won't these libraries being in dependencies increase the production bundle?

EDIT: synthetic answer > as MjZac pointed out in the comments, devDependencies and dependencies are mainly semantics when we are talking about a static web app like React. Also, putting things into dependencies will not impact webpack bundling behavior.

See: https://jsramblings.com/do-dependencies-devdependencies-matter-when-using-webpack/#:~:text=Do%20%22dependencies%22%20and%20%22devDependencies%22%20matter%20when%20using%20Webpack%3F,-12%20Mar%202020&text=When%20using%20Webpack%20to%20bundle,statements%2C%20starting%20with%20the%20entryPoint%20..

3
  • 1
    This is intentionally made so. For context, see github.com/facebook/create-react-app/issues/4342 Commented Nov 25, 2020 at 12:58
  • really interesting Commented Nov 25, 2020 at 13:50
  • this is really bad. I'm getting all kinds of dependency conflicts with these types when trying to include other packages. Commented Aug 9, 2022 at 20:54

1 Answer 1

1

No, they won't be automagically bundled in if they're in dependencies. Only the code you use will be bundled in.

(Nevertheless, I tend to like to have build-time dependencies in devDependencies.)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.