fix(core): skip dependencies already added (avoid circular dependencies) (#9744)
* fix(core): Skip dependencies already added (avoid circular) The project utility method `collectDependentProjectNodesNames()` produces a stack overflow (e.g. producing project dependencies for `tailwind.config.js` when circular dependencies exist. Fix by adding loop detection for "already add" dependencies. * cleanup(core): Correct formating * chore(core): add test for circular dependencies in getSourceDirOfDependentProjects Co-authored-by: Jason Jean <jasonjean1993@gmail.com>
This commit is contained in:
parent
4a91966cb4
commit
8e4a38e764
@ -77,6 +77,18 @@ describe('project graph utils', () => {
|
||||
expect(paths).toContain(projGraph.nodes['core'].data.sourceRoot);
|
||||
});
|
||||
|
||||
it('should handle circular dependencies', () => {
|
||||
projGraph.dependencies['core'] = [
|
||||
{
|
||||
type: 'static',
|
||||
source: 'core',
|
||||
target: 'demo-app',
|
||||
},
|
||||
];
|
||||
const paths = getSourceDirOfDependentProjects('demo-app', projGraph);
|
||||
expect(paths).toContain(projGraph.nodes['ui'].data.sourceRoot);
|
||||
});
|
||||
|
||||
it('should throw an error if the project does not exist', () => {
|
||||
expect(() =>
|
||||
getSourceDirOfDependentProjects('non-existent-app', projGraph)
|
||||
|
||||
@ -139,6 +139,11 @@ function collectDependentProjectNodesNames(
|
||||
continue;
|
||||
}
|
||||
|
||||
// skip dependencies already added (avoid circular dependencies)
|
||||
if (dependencyNodeNames.has(dependencyName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
dependencyNodeNames.add(dependencyName);
|
||||
|
||||
// Get the dependencies of the dependencies
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user