diff --git a/js/package.json b/js/package.json index 0ace90d..e3dc964 100644 --- a/js/package.json +++ b/js/package.json @@ -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" diff --git a/js/src/graph.test.ts b/js/src/graph.test.ts index 5bc92bb..72dbb34 100644 --- a/js/src/graph.test.ts +++ b/js/src/graph.test.ts @@ -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(); + }); }); diff --git a/js/src/graph.ts b/js/src/graph.ts index 23f3b05..0d0ea84 100644 --- a/js/src/graph.ts +++ b/js/src/graph.ts @@ -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]) {