Skip to content

Commit

Permalink
Replace several push calls with a single one
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnns committed Dec 18, 2021
1 parent 0b6d85a commit 9dba017
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions lib/getImportGlobalsSrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,22 @@ function getImportGlobalsSrc(ignore) {
globalObj = typeof global === "undefined"? window: global;

ignore = ignore || [];
// global itself can't be overridden because it's the only reference to our real global objects
ignore.push("global");
// ignore 'module', 'exports' and 'require' on the global scope, because otherwise our code would
// 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");
ignore.push(
// global itself can't be overridden because it's the only reference to our real global objects
"global",
// ignore 'module', 'exports' and 'require' on the global scope, because otherwise our code would
// shadow the module-internal variables
// @see https://github.com/jhnns/rewire-webpack/pull/6
"module", "exports", "require",
// strict mode doesn't allow to (re)define 'undefined', 'eval' & 'arguments'
"undefined", "eval", "arguments",
// 'GLOBAL' and 'root' are deprecated in Node
// (assigning them causes a DeprecationWarning)
"GLOBAL", "root",
// 'NaN' and 'Infinity' are immutable
// (doesn't throw an error if you set 'var NaN = ...', but doesn't work either)
"NaN", "Infinity",
);

const globals = Object.getOwnPropertyNames(globalObj);

Expand Down

0 comments on commit 9dba017

Please sign in to comment.