Search code examples
javascriptglobal-variablesbrowserify

Browserify window object does not have globals


I need to add a global library of the form:

window.Foo = function() {
  api = {};
  api.myVar = GLOBALS;
  return api;
}

to my project using an external script tag. GLOBALS is another variable added to window from another library that window.FOO depends on. However, when I access window in one of my Browserify modules, window.Foo is not there. If I try shimming window.FOO, then its global dependencies are not available to it. I can see and use window.Foo from chrome inspector, though. How do I get the "real" window object in a module? Thank you for any help.


Solution

  • Figured it out! The project was a chrome extension and it was being sandboxed. It had nothing to do with Browserify.