I have an issue presented here.
I have a ParentComponent
which has a child ChildComponent
,
and child has ParentComponent
inside of it so there is a cycle here.
This is the error I'm facing:
✖ Compiling with Angular sources in Ivy partial compilation mode.
ERROR: projects/api/src/lib/api.component.ts:3:1
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.
The component 'ParentComponent' is used in the template but importing
it would create a cycle:
/lib/child/child.component.ts -> /lib/parent/parent.component.ts -> /lib/child/child.component.ts
This error only happens in Angular libraries. So as you can see there is no issue in stackblitz example and it's just a demonstration.
This error goes away with setting "compilationMode": "full"
in library's tsconfig.lib.prod.json
file , but in that case, we loose backward compatibility!
The official doc says:
Move the classes that reference each other into the same file, to avoid any imports between them. Blockquote
And it works, But it's really an ugly way to do that! Also we have lots of components and we just can't do that!
Can you help me PLEASE?!