fix(utils): early return if id is external

This commit is contained in:
Pooya Parsa 2020-01-21 14:05:22 +01:00
parent 042c0ae692
commit 304fb488dc

View File

@ -3,6 +3,10 @@ export function isExternalDependency (id) {
} }
export function clearRequireCache (id) { export function clearRequireCache (id) {
if (isExternalDependency(id)) {
return
}
const entry = getRequireCacheItem(id) const entry = getRequireCacheItem(id)
if (!entry) { if (!entry) {
@ -10,10 +14,6 @@ export function clearRequireCache (id) {
return return
} }
if (isExternalDependency(id)) {
return
}
if (entry.parent) { if (entry.parent) {
entry.parent.children = entry.parent.children.filter(e => e.id !== id) entry.parent.children = entry.parent.children.filter(e => e.id !== id)
} }
@ -26,6 +26,10 @@ export function clearRequireCache (id) {
} }
export function scanRequireTree (id, files = new Set()) { export function scanRequireTree (id, files = new Set()) {
if (isExternalDependency(id) || files.has(id)) {
return files
}
const entry = getRequireCacheItem(id) const entry = getRequireCacheItem(id)
if (!entry) { if (!entry) {
@ -33,10 +37,6 @@ export function scanRequireTree (id, files = new Set()) {
return files return files
} }
if (isExternalDependency(id) || files.has(id)) {
return files
}
files.add(entry.id) files.add(entry.id)
for (const child of entry.children) { for (const child of entry.children) {