tophf пре 3 година
родитељ
комит
50f2a85ca0
1 измењених фајлова са 9 додато и 12 уклоњено
  1. 9 12
      scripts/webpack-protect-bootstrap-plugin.js

+ 9 - 12
scripts/webpack-protect-bootstrap-plugin.js

@@ -55,18 +55,15 @@ class WebpackProtectBootstrapPlugin {
   }
 }
 
-function patchBootstrap(src, group1) {
-  let guard = '';
-  if (group1 !== G.require) {
-    // webpack didn't concatenate all modules into one, let's patch the machinery
-    const props = src.match(new RegExp(`(?<=\\b${G.require}\\.)(\\w+)`, 'g'));
-    const uniq = [...new Set(props)].join('');
-    if (uniq) {
-      guard = `for (let i = 0, props=${JSON.stringify(uniq)}; i < props.length; i++)
-      defineProperty(${G.require}, props[i], {__proto__: null, value: 0, writable: 1});\n`;
-    }
-  }
-  return guard + replace(guard ? BOOTSTRAP_RULES : [OBJ_RULE], src, this);
+function patchBootstrap(src) {
+  const props = src.match(new RegExp(`(?<=\\b${G.require}\\.)(\\w+)`, 'g'));
+  const uniq = [...new Set(props)].join('');
+  const guard = uniq
+    ? `for (let i = 0, props=${JSON.stringify(uniq)}; i < props.length; i++)
+      defineProperty(${G.require}, props[i], {__proto__: null, value: 0, writable: 1});\n`
+    : '';
+  const rules = uniq ? BOOTSTRAP_RULES : [OBJ_RULE];
+  return guard + replace(rules, src, this);
 }
 
 function replace(rules, src, info) {