0

I think I have reasonable understanding of what npm peer dependencies are and why we need them. A common example is grunt modules. If you are writing a grunt module that is only compatible with version x of grunt, you have to make sure anyone using your grunt module is also using version x of grunt. Makes sense.

However, angular2 has a peer dependency on zone.js. What is the relationship between angular2 and zone.js such that this peer dependency is required? Why can't zone.js be a standard dependency of angular2?

In the grunt example, you can use grunt just fine without the module in question. However, it does not seem possible to use angular2 without zonejs. Seems like more of a standard dependency rather than a peer.

d512
  • 32,267
  • 28
  • 81
  • 107
  • Because this is *peer* dependency indeed. `zone.js` prollyfill should be installed by the app and A2 relies on that. Having `zone.js` as a dependency may result in having multiple copies of the package. – Estus Flask Nov 13 '16 at 22:21
  • @estus, yes, but the ability to support multiple versions of the same library is one of npm's features. Normally that's okay. In this case it's not though and I don't understand what makes this case different. – d512 Nov 14 '16 at 04:23
  • It is not just a random CommonJS library but a prollyfill that should be set up globally only once. And this is done by app that has `zone.js` a a dependency, not by A2 itself. – Estus Flask Nov 14 '16 at 04:36
  • So is it possible to use angular2 without zone.js? – d512 Nov 14 '16 at 14:44
  • No. Zones are proposed standard. If they will be standardized and implemented, it may be possible. It isn't possible to use A2 without `Promise` either, but it doesn't have promise polyfill as a dependency. – Estus Flask Nov 14 '16 at 14:55

0 Answers0