Skip to content

Commit

Permalink
[fix] Use explicit require of wsEngine (#523)
Browse files Browse the repository at this point in the history
Because WebPack does not support variables in require statements.

Closes #522
  • Loading branch information
markbjerke authored and darrachequesne committed Sep 2, 2017
1 parent f9d3f06 commit 38d639a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ Server.prototype.init = function () {

var wsModule;
try {
wsModule = require(this.wsEngine);
switch (this.wsEngine) {
case 'uws': wsModule = require('uws'); break;
case 'ws': wsModule = require('ws'); break;
default: throw new Error('unknown wsEngine');
}
} catch (ex) {
this.wsEngine = 'ws';
// keep require('ws') as separate expression for packers (browserify, etc)
Expand Down

0 comments on commit 38d639a

Please sign in to comment.