From d4aed71abfb272d8a35b8d0e4b458949343881aa Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 29 Mar 2013 18:27:48 -0700 Subject: [PATCH] Make Lo-Dash work with Browserify. [closes #223] Former-commit-id: 33b53dd075d6c4ed9682881af463bdd3c241ca44 --- build.js | 2 +- build/pre-compile.js | 1 + lodash.js | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/build.js b/build.js index 65e5b357e..55ea15f09 100755 --- a/build.js +++ b/build.js @@ -510,7 +510,7 @@ " var freeModule = typeof module == 'object' && module && module.exports == freeExports && module;", '', " var freeGlobal = typeof global == 'object' && global;", - ' if (freeGlobal.global === freeGlobal) {', + ' if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {', ' window = freeGlobal;', ' }', '', diff --git a/build/pre-compile.js b/build/pre-compile.js index 69ef77732..8e403158b 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -214,6 +214,7 @@ 'values', 'variable', 'where', + 'window', 'without', 'wrap', 'zip', diff --git a/lodash.js b/lodash.js index 3b4d6db5c..b58fce06a 100644 --- a/lodash.js +++ b/lodash.js @@ -17,9 +17,9 @@ /** Detect free variable `module` */ var freeModule = typeof module == 'object' && module && module.exports == freeExports && module; - /** Detect free variable `global` and use it as `window` */ + /** Detect free variable `global`, from Node.js or Browserified code, and use it as `window` */ var freeGlobal = typeof global == 'object' && global; - if (freeGlobal.global === freeGlobal) { + if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) { window = freeGlobal; }