I have a very simple wrapper module around a global object set by the environment the scripts are run. The wrapper module simply does:
module.exports = global.foobar;
Previously when I used browserify this worked fine. When in the browser, global
was the same as window
.
However, I'm switching to webpack and after running webpack the meaning of global
has changed. In the browser it's no longer an alias to window
, instead it's undefined
, and I get cannot read property foobar of undefined
.
Now, in the case of my wrapper module I can fix that in other ways, but I have other dependencies, and further down the chain the buffer
package is used. That package also uses global
(see here) and also crashes after I've run webpack:
Uncaught TypeError: Cannot read property 'TYPED_ARRAY_SUPPORT' of undefined
Is there some way I can make webpack treat global
the same way browserify did, with global
being an alias of window
?