I am working on upgrading an library from Angular 12 to Angular 13 which is used in another angular application. I have a case where components will be used in cyclic manner.
Example
one.component.ts:
@Component({
selector: 'lib-one',
template: `<div><lib-two></lib-two></div>`,
styles: [],
})
export class OneComponent {}
two.component.ts:
@Component({
selector: 'lib-two',
template: `<div><lib-one></lib-one></div>`,
styles: [],
})
export class TwoComponent {}
When I try to build the library, I get an error like:
error NG3003: One or more import cycles would need to be created to compile this component, which is not supported by the current compiler configuration.
One way of handling this is to remove the below code from tsconfig.lib.prod.json
"angularCompilerOptions": {
"compilationMode": "partial"
}
Is there any other way to handle this?
Please note components one and two can be in different modules and are being used circular way depending on some conditions.
Thanks in advance.