Home > OS >  Why do we need dependencies and devDependencies if babel knows how to build efficiently and remove e
Why do we need dependencies and devDependencies if babel knows how to build efficiently and remove e

Time:02-02

I have read a lot of articles that say that the dependencies that are specified in the dependencies block are added to the build and the project will not start without them. I did so, transferred absolutely all the dependencies in the webpack to the devDependencies block and assembled the assemblies and launched the project. It starts off great, I come to the conclusion that there is absolutely no difference where to specify a dependency in the devDependencies or dependencies block. There is an assumption that babel "runtime": "automatic" itself knows how to control everything. If I'm wrong, please correct me.

Here is an example of my project enter image description here

CodePudding user response:

As the name says, dev dependencies are tools that you need for development. for example, when you work with webpack, you need a lot of packages for webpack, "webpack" itself, maybe "webpack-dev-server" or other plugins. And also for babel set up, you need alot of other packages. All of those are needed to create the final bundle. After creating a bundle you do not need these packages, so when you deploy your app, your server does not need to install those and maintain those. Your app in production will run without those.

Packages that you need for testing are also dev dependencies. you test the app in the dev environment, not in a production environment.

On the other hand, if you have a database connection package, this is the dependency that your project needs when you deploy the app. Otherwise, your clients will not be able to connect database. In fact if you install a dependency as dev-dependency by mistake, when you deploy the app your app will give errors. Dependencies are essential packages that your app need in production.

  • Related