-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from adzialocha/fix-externals
Fix `ws` and `dgram` externals for browser environments
- Loading branch information
Showing
11 changed files
with
395 additions
and
348 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// This file gets used instead of the NodeJS `dgram` module during rollup | ||
// builds targeting browser environments. It simply returns "nothing". | ||
const noop = undefined | ||
export default noop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// This file gets used instead of the `ws` package during rollup builds | ||
// targeting browser environments. | ||
let ws | ||
|
||
if (typeof WebSocket !== 'undefined') { | ||
ws = WebSocket | ||
} else if (typeof MozWebSocket !== 'undefined') { | ||
ws = MozWebSocket | ||
} else if (typeof global !== 'undefined') { | ||
ws = global.WebSocket || global.MozWebSocket | ||
} else if (typeof window !== 'undefined') { | ||
ws = window.WebSocket || window.MozWebSocket | ||
} else if (typeof self !== 'undefined') { | ||
ws = self.WebSocket || self.MozWebSocket | ||
} | ||
|
||
/** | ||
* Do not export server for browser environments. | ||
* @private | ||
*/ | ||
export const WebSocketServer = undefined | ||
|
||
/** | ||
* Return WebSocket client for browser environments. | ||
* @private | ||
*/ | ||
export default ws |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters