Skip to content

Commit d873a91

Browse files
Fix Webpack global scope issue
In webpack 4 (Angular 8) the `_global = ...` will return undefined causing "Cannot read property WebSocket of undefined"
1 parent 6e62787 commit d873a91

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/browser.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
var _global = (function() { return this; })();
1+
var _global = (function () {
2+
if (!this && typeof global !== 'undefined') {
3+
return global;
4+
}
5+
return this;
6+
})();
27
var NativeWebSocket = _global.WebSocket || _global.MozWebSocket;
38
var websocket_version = require('./version');
49

0 commit comments

Comments
 (0)