Skip to content

Commit 85e544a

Browse files
fix: remove explicit require of uws
So that bundlers like webpack do not try to include it in the build. As a side-effect, any implementation which matches the API of the ws module can now be used. Before that change, you had to explicitly exclude uws: ``` // webpack.config.js module.exports = { // ... externals: { uws: 'uws' } }; ``` Related: #575 Backported from master: 82cdca2
1 parent e488120 commit 85e544a

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lib/server.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,8 @@ Server.prototype.init = function () {
102102

103103
if (this.ws) this.ws.close();
104104

105-
var wsModule;
106-
switch (this.wsEngine) {
107-
case 'uws': wsModule = require('uws'); break;
108-
case 'ws': wsModule = require('ws'); break;
109-
default: throw new Error('unknown wsEngine');
110-
}
105+
// add explicit require for bundlers like webpack
106+
var wsModule = this.wsEngine === 'ws' ? require('ws') : require(this.wsEngine);
111107
this.ws = new wsModule.Server({
112108
noServer: true,
113109
clientTracking: false,

0 commit comments

Comments
 (0)