1

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.

1 Answer 1

-1

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!

Sign up to request clarification or add additional context in comments.

3 Comments

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.
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
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.