Skip to content

Commit

Permalink
fix(utils): early return if id is external
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jan 21, 2020
1 parent 042c0ae commit 304fb48
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/utils/src/cjs.js
Expand Up @@ -3,17 +3,17 @@ export function isExternalDependency (id) {
}

export function clearRequireCache (id) {
if (isExternalDependency(id)) {
return
}

const entry = getRequireCacheItem(id)

if (!entry) {
delete require.cache[id]
return
}

if (isExternalDependency(id)) {
return
}

if (entry.parent) {
entry.parent.children = entry.parent.children.filter(e => e.id !== id)
}
Expand All @@ -26,17 +26,17 @@ export function clearRequireCache (id) {
}

export function scanRequireTree (id, files = new Set()) {
if (isExternalDependency(id) || files.has(id)) {
return files
}

const entry = getRequireCacheItem(id)

if (!entry) {
files.add(id)
return files
}

if (isExternalDependency(id) || files.has(id)) {
return files
}

files.add(entry.id)

for (const child of entry.children) {
Expand Down

0 comments on commit 304fb48

Please sign in to comment.