Skip to content

Commit

Permalink
fix: wrong cyclic check on mutal deps
Browse files Browse the repository at this point in the history
  • Loading branch information
vanhtuan0409 committed Jan 31, 2024
1 parent 7b9c214 commit 6b866fb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@anduintransaction/rivendell",
"version": "0.5.2",
"version": "0.5.3",
"repository": {
"type": "git",
"url": "git+https://github.com/anduintransaction/rivendell.git"
Expand Down
12 changes: 12 additions & 0 deletions js/src/graph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,16 @@ describe("graph test", () => {
ModuleGraph.resolve(...modules);
}).toThrow();
});

test("should not throw cyclic [1]", () => {
const modules: Module[] = [
new Module("l1"),
new Module("l2.1", { deps: ["l1"] }),
new Module("l2.2", { deps: ["l1"] }),
new Module("l3", { deps: ["l2.1", "l2.2"] }),
];
expect(() => {
ModuleGraph.resolve(...modules);
}).not.toThrow();
});
});
2 changes: 1 addition & 1 deletion js/src/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class ModuleGraph {
}

for (const candidate of this.roots) {
for (const item of Walker.dfs(this, candidate)) {
for (const item of Walker.bfs(this, candidate)) {
const children = this.children[item.m.name];
for (const child of children) {
if (item.visited[child]) {
Expand Down

0 comments on commit 6b866fb

Please sign in to comment.