-
Notifications
You must be signed in to change notification settings - Fork 46
Changed browser to es modules #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import WebSocket from 'isomorphic-ws' | ||
|
||
|
||
const ws = new WebSocket('ws://www.host.com/path') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// https://github.com/maxogden/websocket-stream/blob/48dc3ddf943e5ada668c31ccd94e9186f02fafbd/ws-fallback.js | ||
|
||
var ws = null; | ||
|
||
if (typeof WebSocket !== 'undefined') { | ||
ws = WebSocket; | ||
} else if (typeof MozWebSocket !== 'undefined') { | ||
ws = MozWebSocket; | ||
} else if (typeof global !== 'undefined') { | ||
ws = global.WebSocket || global.MozWebSocket; | ||
Comment on lines
+9
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moreover, checking for global is useless here, because this is a node.js object
|
||
} else if (typeof window !== 'undefined') { | ||
ws = window.WebSocket || window.MozWebSocket; | ||
} else if (typeof self !== 'undefined') { | ||
ws = self.WebSocket || self.MozWebSocket; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we throw an error when no WebSocket detected, like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can better use "globalThis"? |
||
var WebSocket$1 = ws; | ||
|
||
new WebSocket$1('ws://www.host.com/path'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like a breaking change, the major version number should be changed when we publish it🤔