fix(module): protect clearRequireCache against infinite recursion (#7966)

This commit is contained in:
netkin-paris 2020-08-26 11:36:39 +02:00 committed by GitHub
parent 447340e91c
commit 7cecbccabd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,11 +20,12 @@ export function clearRequireCache (id) {
entry.parent.children = entry.parent.children.filter(e => e.id !== id)
}
// Needs to be cleared before children, to protect against circular deps (#7966)
delete require.cache[id]
for (const child of entry.children) {
clearRequireCache(child.id)
}
delete require.cache[id]
}
export function scanRequireTree (id, files = new Set()) {