Update to 10.2.0 results a huge amount of circular dependencies lint errors
See original GitHub issueCurrent Behavior
Circular dependencies suddenly occur after update to 10.2.0
Expected Behavior
Circular dependencies should not suddenly occur after update to 10.2.0. No issues on 10.1.0.
Steps to Reproduce
I’m afraid I can’t share my repo. But I have 2 libraries:
shared/components shared/services
shared/components imports from shared/services, but shared/services doesn’t import shared/components. I have double checked this.
Still after updating to 10.2.0 I suddenly get:
ERROR: 3:1 nx-enforce-module-boundaries Circular dependency between “shared-components” and “shared-services” detected.
This is just one example, I have loads of them.
I have opened up the runtime-lint-utils and added some console logging and for all I can conclude is that i goes looking up any other libs containing imports of shared-services and if those other libs are also importing shared-components, it resolves to true.
there is a funny twist in the code I noticed also:
export function isCircular(
graph: ProjectGraph,
sourceProject: ProjectGraphNode,
targetProject: ProjectGraphNode
): boolean {
if (!graph.nodes[targetProject.name]) return false;
return isDependingOn(graph, targetProject.name, sourceProject.name);
}
function isDependingOn(
graph: ProjectGraph,
sourceProjectName: string,
targetProjectName: string,
done: { [projectName: string]: boolean } = {}
):
see how targetProject and sourceProject are flipped as arguments?
Environment
nx : Not Found @nrwl/angular : 10.2.0 @nrwl/cli : 10.2.0 @nrwl/cypress : 10.2.0 @nrwl/eslint-plugin-nx : Not Found @nrwl/express : Not Found @nrwl/jest : 10.2.0 @nrwl/linter : Not Found @nrwl/nest : Not Found @nrwl/next : Not Found @nrwl/node : Not Found @nrwl/react : Not Found @nrwl/schematics : Not Found @nrwl/tao : 10.2.0 @nrwl/web : Not Found @nrwl/workspace : 10.2.0 typescript : 3.9.7
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:21 (6 by maintainers)
YES! I can report back that the issues are gone. Though I had to do a second run after fixing imports from
'..'
as well. But after this, the linting errors have disappeared!I should be nice if we could have some additional linting that will throw lint errors when importing in this way (
'..'
and'.'
)!@FrozenPandaz ok, the issue is that this utility function https://github.com/nrwl/nx/blob/e9393805c175e9b7e5a94aca71fa654970ccb802/packages/workspace/src/utils/fileutils.ts#L114 does not recognize
'.'
as a valid relative path, resulting in broken logic starting here https://github.com/nrwl/nx/blob/be921083553bea0cbf6f87f3679489ce924917bf/packages/workspace/src/core/target-project-locator.ts#L50'.'
must not be anormalizedImportExpr
.So I think this should be the only use case that is left missing. @EvtK can you confirm if your code base has imports from
'.'
?