Create an angular library which can be consumed by lower versions of angular project
Asked Answered
B

1

7

I have some common components in my angular 12 application which I am planning to create as an angular library so that other applications can also use it. We have some applications running on lower version of angular (e.g. angular 8 / angular 10) which will also use this common library.

I already created library in angular 12 which is working fine in angular 12 application. However, it is not working in other applications which are using angular 8 and angular 10.

Getting error like :

fesm2015/common-lib.js 12:145-163 "export 'ɵɵFactoryTarget' (imported as 'i0') was not found in '@angular/core'

So, the main confusion is do I need create 3 different angular library for v8, v8 and v12 application. Or is there any way that I can create one library which can be consumed by all 3 angular applications (ver 8/10/12).

Please suggest the right way to proceed.

Buffer answered 3/12, 2021 at 11:22 Comment(1)
Perhaps this be accomplished by exporting the Angular library as a web component and then importing the web component into the consuming application?Rodrich
E
7

I have faced with same issue, and found a comment from Angular team member: https://github.com/angular/angular/issues/43949#issuecomment-951845346

So, Angular doesn't support usage of libraries that were produced higher versions of Angular than a version of consumed Application.

Experimentalize answered 2/2, 2022 at 11:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.