-2

Lets say for example I have an angular application built with the Angular v6 cli and that depends on an Angular library built with the Angular v8 cli. Is it safe to use this library as a dependency or should the application be updated to angular v8?

Same question for the opposite scenario. If my application is built with angular v8 cli and it depends on an Angular library built with the Angular v6 cli, should the Angular library be updated to build with Angular v8 cli?

Fergal Rooney
  • 1,330
  • 2
  • 18
  • 31

1 Answers1

1

Well, if it compiles and you have tests in your code, I think it's completely safe in terms of features. But you must have written tests for your code to make sure all the features you need from the libraries are working correctly (you don't need to test the library, of course, just the integration of its features into your components).

From the security point of view, you're open to out-of-date nano dependencies security flaws not corrected in the out-of-date libraries (this is the cancer of javascript projects: nano dependencies).

Using a library built upon a greater version of angular than that in your project may or may not work. If the author of the library specified the version as a peerDependency something like @angular/core:^8.0 and you're trying to use it in a @angular 6 project, you'll get a warning during npm install and may have trouble during runtime (if the author have real reasons to specify that version as a peer dependency).

It's not uncommon for the authors to just keep the peer dependencies up to date, so it is possible in many cases to ignore the warning messages during the build and use the library. But to do it in a trustful way, you must have a bunch of tests covering the features you're using from that library.

julianobrasil
  • 8,954
  • 2
  • 33
  • 55
  • Yes I've often wondered about the peerDependencies warning and whether or not it is safe to use that dependency. Agree that if you have proper test coverage, this should give you a level of comfort to proceed to use a library built with a different version. I'm guessing a major update like Angular 9 might be a different story due to the Ivy compiler but I believe you can opt in to use ViewEngine for angular 9 libraries to maintain compatibility with non ivy applications. – Fergal Rooney Apr 24 '20 at 16:02
  • Currently you can't use angular ivy in libraries. But that time will come. – julianobrasil Apr 24 '20 at 16:44