Skip to content

Commit dbdc39d

Browse files
committed
refactor maintemplate to handle set instead of array
1 parent 7972859 commit dbdc39d

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/MainTemplate.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,16 @@ module.exports = class MainTemplate extends Template {
199199

200200
entryPointInChildren(chunk) {
201201
const checkChildren = (chunk, alreadyCheckedChunks) => {
202-
return chunk.chunks.some((child) => {
203-
if(alreadyCheckedChunks.indexOf(child) >= 0) return;
204-
alreadyCheckedChunks.push(child);
205-
return child.hasEntryModule() || checkChildren(child, alreadyCheckedChunks);
206-
});
202+
for(const child of chunk.getChunks()) {
203+
if(!alreadyCheckedChunks.has(child)) {
204+
alreadyCheckedChunks.add(child);
205+
if(child.hasEntryModule() || checkChildren(child, alreadyCheckedChunks)) {
206+
return true;
207+
}
208+
}
209+
}
207210
};
208-
return checkChildren(chunk, []);
211+
return checkChildren(chunk, new Set()) === true;
209212
}
210213

211214
getPublicPath(options) {

0 commit comments

Comments
 (0)