Skip to content

Commit

Permalink
Add depth counter to avoid recursive overlap
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacl committed Nov 1, 2020
1 parent e45652d commit 59e703c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/extractLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ function evalDependencyGraph({loaderContext, src, filename, publicPath = ""}) {
plugins: [require("babel-plugin-add-module-exports")],
}).code;

const curVmDepth = global.__EXTRACT_LOADER_PLACEHOLDER__DEPTH__ || 0;

const script = new vm.Script(src, {
filename,
displayErrors: true,
Expand Down Expand Up @@ -147,7 +149,7 @@ function evalDependencyGraph({loaderContext, src, filename, publicPath = ""}) {
return exports;
}

const extractPlaceholder = "__EXTRACT_LOADER_PLACEHOLDER__" + counterNumber() + "__";
const extractPlaceholder = "__EXTRACT_LOADER_PLACEHOLDER__" + curVmDepth + "__" + counterNumber() + "__";

newDependencies.push({
absolutePath,
Expand All @@ -157,6 +159,7 @@ function evalDependencyGraph({loaderContext, src, filename, publicPath = ""}) {

return extractPlaceholder;
},
__EXTRACT_LOADER_PLACEHOLDER__DEPTH__: curVmDepth + 1,
});

script.runInNewContext(sandbox);
Expand Down

0 comments on commit 59e703c

Please sign in to comment.