0

I have a component X which imports a component Y.

In componentx.model.ts I defined some types and interfaces.

In component Y I would like to use one of these interfaces so I import it with import { NiceInterface } from '@foo/bar/componentx';

The result is that when I run ng-packagr I get the following error:

Entry point @foo/bar/componentx has a circular dependency on @foo/bar/componenty.

I don't really understand that because I import that interface, nothing else.

Juuro
  • 1,487
  • 5
  • 16
  • 27

1 Answers1

0

I would need to see more of your code to be certain, but I've ran into this several times before. In my experience this is what I usually run into:

  1. FirstItem imports interface SecondItem
  2. SecondItem imports a model or interface ThirdItem
  3. ThirdItem imports FirstItem.

When this happens, it creates a circular dependency and the ng-packagr output for the error only really tells you the two items causing the issue and doesn't output the middle parts.

If it's not a chain of imports, hopefully at least running through this helps you you find the issue!

RG3
  • 61
  • 4
  • It's not really a chin of imports. The are only two items. ComponentX imports ComponentY and ComponentY imports an interface that's defined in ComponentX. That's it. My problem is I don't see a solution to do it differently. Also it works perfectly fine in the browser. – Juuro Apr 28 '23 at 15:51
  • I see, I must have misunderstood the question. For clarification, are you saying that ComponentY imports the interface that's in the same file as ComponentX? Because that would be your issue, you would need to move the interface to a new file, update the imports correctly, and that should solve your issue – RG3 Apr 28 '23 at 15:53
  • It is in the .model file of ComponentX. Yeah, I know *that* solution, but in my case it's not a solution because the interface declarations have to be in the same directory as the component so they show up in the automatically generated documentation. – Juuro Apr 28 '23 at 15:57