fake-timers: ReferenceError when using npm package in the browser; get global object properly
I know you might to say “use bower”…but no. React devs use npm for everything these days, including for the browser, and we’re used to npm packages working in both node and the browser (i.e. via webpack).
Usually when I need access to the global object, I do
var global = (new Function("return this"))()
Works in node and the browser.
Alternative you could call your bootstrap function with
(typeof global !== 'undefined' ? global : this)
(see http://stackoverflow.com/questions/3277182/how-to-get-the-global-object-in-javascript)
Whether you want to use that or some other solution, please make sure that src/lolex-src.js works even if accessing global would cause a ReferenceError.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (15 by maintainers)
Would not dream of saying such a thing. Who uses Bower anyway these days? 😉 Just update #72 to pass the linting and this should be fixed.