Skip to content

Commit

Permalink
Use isOwnPath() guard to avoid removing esm modules from cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Sep 17, 2018
1 parent ba46371 commit c13d4ee
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.js
Expand Up @@ -22,6 +22,7 @@ import errors from "./errors.js"
import globalHook from "./hook/global.js"
import isInstalled from "./util/is-installed.js"
import isObject from "./util/is-object.js"
import isOwnPath from "./util/is-own-path.js"
import isSideloaded from "./env/is-sideloaded.js"
import keys from "./util/keys.js"
import mainHook from "./hook/main.js"
Expand Down Expand Up @@ -127,10 +128,9 @@ if (shared.inited &&
globalHook(shared.unsafeGlobal)
} else if (! isSideloaded()) {
const { _cache } = Module
const { id } = __non_webpack_module__

for (const name in _cache) {
if (name !== id) {
if (! isOwnPath(name)) {
Reflect.deleteProperty(_cache, name)
}
}
Expand Down

0 comments on commit c13d4ee

Please sign in to comment.