From 59e703cf8280acddbbfd304c0c58535a87394ce4 Mon Sep 17 00:00:00 2001 From: Isaac Levy Date: Sun, 1 Nov 2020 18:03:01 -0500 Subject: [PATCH] Add depth counter to avoid recursive overlap --- src/extractLoader.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/extractLoader.js b/src/extractLoader.js index d51a5cc..7f1abf8 100644 --- a/src/extractLoader.js +++ b/src/extractLoader.js @@ -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, @@ -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, @@ -157,6 +159,7 @@ function evalDependencyGraph({loaderContext, src, filename, publicPath = ""}) { return extractPlaceholder; }, + __EXTRACT_LOADER_PLACEHOLDER__DEPTH__: curVmDepth + 1, }); script.runInNewContext(sandbox);