Skip to content

Commit 7fcddcb

Browse files
authored
fix(engine.io-client): correctly consume the ws package (#5220)
This should fix the following issue: ``` SyntaxError: Named export 'WebSocket' not found. The requested module 'ws' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using: import pkg from 'ws'; const { WebSocket } = pkg; ```
1 parent 7427109 commit 7fcddcb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/engine.io-client/lib/transports/websocket.node.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { WebSocket } from "ws";
1+
import * as ws from "ws";
22
import type { Packet, RawData } from "engine.io-parser";
33
import { BaseWS } from "./websocket.js";
44

@@ -27,7 +27,7 @@ export class WS extends BaseWS {
2727
opts.headers.cookie.push(`${name}=${cookie.value}`);
2828
}
2929
}
30-
return new WebSocket(uri, protocols, opts);
30+
return new ws.WebSocket(uri, protocols, opts);
3131
}
3232

3333
doWrite(packet: Packet, data: RawData) {

0 commit comments

Comments
 (0)