Skip to content

Commit 7e0a6ca

Browse files
committed
fix contrains checks, might get obsolete in the future
1 parent 60900aa commit 7e0a6ca

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

lib/Chunk.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,16 +448,19 @@ class Chunk {
448448

449449
checkConstraints() {
450450
const chunk = this;
451-
chunk._chunks.forEach((child, idx) => {
452-
if(Array.from(chunk._chunks).indexOf(child) !== idx)
451+
const chunks = Array.from(chunk._chunks);
452+
chunks.forEach((child, idx) => {
453+
if(chunks.indexOf(child) !== idx)
453454
throw new Error(`checkConstraints: duplicate child in chunk ${chunk.debugId} ${child.debugId}`);
454455
if(child.parents.indexOf(chunk) < 0)
455456
throw new Error(`checkConstraints: child missing parent ${chunk.debugId} -> ${child.debugId}`);
456457
});
457458
chunk.parents.forEach((parentChunk, idx) => {
458459
if(chunk.parents.indexOf(parentChunk) !== idx)
459460
throw new Error(`checkConstraints: duplicate parent in chunk ${chunk.debugId} ${parentChunk.debugId}`);
460-
if(parentChunk._chunks.indexOf(chunk) < 0)
461+
462+
const chunks = Array.from(parentChunk._chunks);
463+
if(chunks.indexOf(chunk) < 0)
461464
throw new Error(`checkConstraints: parent missing child ${parentChunk.debugId} <- ${chunk.debugId}`);
462465
});
463466
}

test/Chunk.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ describe("Chunk", () => {
128128
});
129129
describe("and the chunk does contain this module", function() {
130130
beforeEach(function() {
131-
ChunkInstance.chunks = [chunk];
131+
ChunkInstance._chunks = new Set([chunk]);
132132
});
133133
it("calls module.removeChunk with itself and returns true", function() {
134134
ChunkInstance.removeChunk(chunk).should.eql(true);

0 commit comments

Comments
 (0)