diff --git a/lib/server.js b/lib/server.js index 3fbee3e07..6d998e8fb 100644 --- a/lib/server.js +++ b/lib/server.js @@ -102,12 +102,8 @@ Server.prototype.init = function () { if (this.ws) this.ws.close(); - var wsModule; - switch (this.wsEngine) { - case 'uws': wsModule = require('uws'); break; - case 'ws': wsModule = require('ws'); break; - default: throw new Error('unknown wsEngine'); - } + // add explicit require for bundlers like webpack + var wsModule = this.wsEngine === 'ws' ? require('ws') : require(this.wsEngine); this.ws = new wsModule.Server({ noServer: true, clientTracking: false,