question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Circular dependencies detection do not exclude tests in buildable libraries

See original GitHub issue

Current Behavior

I can’t build a buildable library because NX is detecting wrong circular dependecies.

I have two buildable libraries in a project, the first library creates a value object to make a date inmutable, the second library generates random instance of the first library (for test purpouses).

I write a test for the first library, in this test, I import the second library and the tests works properly but if I try to build the application I get a circular dependency error.

However, if I build the library using the command npx tsc --project libs\shared\domain\timestamp\tsconfig.lib.json the library builds without no problem and no circular dependencies.

This is the current dep graph of the application:

graph

I think the problem comes from the dependency detection, he should ignore the test files.

Expected Behavior

I should be able to build the library without a circular dependency error.

Steps to Reproduce

I have created a repo with the example https://github.com/abrahamsaanchez/circular-dependencies

Failure Logs

> NX Could not execute shared/domain/timestamp:build because it has a circular dependency

Environment

>  NX   Report complete - copy this into the issue template

   Node : 16.13.2
   OS   : win32 x64
   npm  : 8.4.1

   nx : 13.9.5
   @nrwl/angular : Not Found
   @nrwl/cypress : Not Found
   @nrwl/detox : Not Found
   @nrwl/devkit : 13.9.5
   @nrwl/eslint-plugin-nx : 13.9.5
   @nrwl/express : Not Found
   @nrwl/jest : 13.9.5
   @nrwl/js : 13.9.5
   @nrwl/linter : 13.9.5
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : 13.9.5
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : Not Found
   @nrwl/workspace : 13.9.5
   typescript : 4.5.5
   rxjs : 6.6.7
   ---------------------------------------
   Community plugins:

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:4
  • Comments:5

github_iconTop GitHub Comments

1reaction
dereekbcommented, May 14, 2022

Found a solution, you can use the implicitDependencies configuration to ignore dependencies.

https://github.com/nrwl/nx/issues/10290#issuecomment-1126635073

0reactions
abrahamsaanchezcommented, Nov 13, 2022

Up this

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Eliminate Circular Dependencies from Your JavaScript ...
In my experience, the best way to deal with circular dependencies is to avoid them altogether. Circular dependencies are usually an indication ...
Read more >
How to solve cyclic dependency between different modules in ...
1.Go to project-> java compiler-> building -> Enable project specific settings. Select build path problems and give warning as option for ...
Read more >
NG0200: Circular dependency in DI detected while ... - Angular
Break this loop (or circle) of dependency to resolve this error. This most commonly means removing or refactoring the dependencies to not be...
Read more >
How to Analyze Circular Dependencies in ES6? - Railsware
They are not always evil, but you might want to treat them with special care. They cause tight coupling of the mutually dependent...
Read more >
Gradle dependencies | IntelliJ IDEA Documentation - JetBrains
The best way to add or manage a dependency is in the build.gradle file. ... IntelliJ IDEA also indicates cyclic dependencies in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found