From 304fb488dc0af6517bee92d802f8f6042acace5d Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 21 Jan 2020 14:05:22 +0100 Subject: [PATCH] fix(utils): early return if id is external --- packages/utils/src/cjs.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/utils/src/cjs.js b/packages/utils/src/cjs.js index 1add0c35f0..c70825b20f 100644 --- a/packages/utils/src/cjs.js +++ b/packages/utils/src/cjs.js @@ -3,6 +3,10 @@ export function isExternalDependency (id) { } export function clearRequireCache (id) { + if (isExternalDependency(id)) { + return + } + const entry = getRequireCacheItem(id) if (!entry) { @@ -10,10 +14,6 @@ export function clearRequireCache (id) { return } - if (isExternalDependency(id)) { - return - } - if (entry.parent) { 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()) { + if (isExternalDependency(id) || files.has(id)) { + return files + } + const entry = getRequireCacheItem(id) if (!entry) { @@ -33,10 +37,6 @@ export function scanRequireTree (id, files = new Set()) { return files } - if (isExternalDependency(id) || files.has(id)) { - return files - } - files.add(entry.id) for (const child of entry.children) {