Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why aren't all angular packages declared as devDependencies?

Tags:

angular

I know node/express. I know the difference between dependencies and devDependencies.

I'm learning angular. I've been through the official tutorial.

I thought an angular app is compiled - at development time - into a set of static files. Those files are uploaded to some server. Once they are downloaded by a client, all the action takes place in the client, except when it reaches out to my node/express server for data.

So I don't understand why a scaffolded angular project has a package.json with both dependencies and devDependencies. I assumed everything would be in devDependencies, because there is no package.json at runtime, only the bootstrapping html file and then all the compiled javascripts.

I'm obviously misunderstanding the deployment stage. Please correct me where I'm wrong.

like image 434
lonix Avatar asked Dec 13 '25 04:12

lonix


1 Answers

I think found the answer.

Both deps and devdeps are only used during development-time, rather than at run-time (because there's no manifest at runtime, only html and compiled scripts). That was the source of my confusion.

However the compilation stage only compiles and bundles references found in the deps.

Add to that

  1. tree shaking, and
  2. you may inadvertantly eliminate downstream modules (if referenced as devdeps rather than deps), means that they must be in the deps section.

So this is a semantic clue for the compiler to know what to bundle - it's not an issue of devtime vs runtime. So it was confusing because that's a subtle difference to how this works on the server side.

like image 69
lonix Avatar answered Dec 15 '25 20:12

lonix



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!