Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
support WebPack, changed Server.prototype.init so that default choice…
…s don't preclude bundling with WebPack for node target
  • Loading branch information
markbjerke committed Jul 29, 2017
commit 8b4267b6d295b8bcbc0de40dba8c51093f12a2d8
15 changes: 14 additions & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,20 @@ Server.prototype.init = function () {

var wsModule;
try {
wsModule = require(this.wsEngine);
// support WebPack with static require(s) if possible...
switch(this.wsEngine) {
case 'uws':
wsModule = require('uws');
break;

case 'ws':
wsModule = require('ws');
break;
// only this case breaks the ability to WebPack engine.io, warning can be safely ignored
default:
wsModule = require(this.wsEngine);
}

} catch (ex) {
this.wsEngine = 'ws';
// keep require('ws') as separate expression for packers (browserify, etc)
Expand Down