diff options
Diffstat (limited to 'lib/getImportGlobalsSrc.js')
-rw-r--r-- | lib/getImportGlobalsSrc.js | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/getImportGlobalsSrc.js b/lib/getImportGlobalsSrc.js index 3c29c56..fcce0d0 100644 --- a/lib/getImportGlobalsSrc.js +++ b/lib/getImportGlobalsSrc.js @@ -9,7 +9,6 @@ */ function getImportGlobalsSrc(ignore) { var key, - value, src = "", globalObj = typeof global === "undefined"? window: global; @@ -20,12 +19,21 @@ function getImportGlobalsSrc(ignore) { // shadow the module-internal variables // @see https://github.com/jhnns/rewire-webpack/pull/6 ignore.push("module", "exports", "require"); + // strict mode doesn't allow to (re)define 'undefined', 'eval' & 'arguments' + ignore.push("undefined", "eval", "arguments"); + // 'GLOBAL' and 'root' are deprecated in Node + // (assigning them causes a DeprecationWarning) + ignore.push("GLOBAL", "root"); + // 'NaN' and 'Infinity' are immutable + // (doesn't throw an error if you set 'var NaN = ...', but doesn't work either) + ignore.push("NaN", "Infinity"); - for (key in globalObj) { /* jshint forin: false */ + const globals = Object.getOwnPropertyNames(globalObj); + + for (key of globals) { if (ignore.indexOf(key) !== -1) { continue; } - value = globalObj[key]; // key may be an invalid variable name (e.g. 'a-b') try { |