Skip to content

Commit

Permalink
fix(engine.io-client): correctly consume the ws package (#5220)
Browse files Browse the repository at this point in the history
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;
```
  • Loading branch information
benmccann authored Jan 7, 2025
1 parent 7427109 commit 7fcddcb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/engine.io-client/lib/transports/websocket.node.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WebSocket } from "ws";
import * as ws from "ws";
import type { Packet, RawData } from "engine.io-parser";
import { BaseWS } from "./websocket.js";

Expand Down Expand Up @@ -27,7 +27,7 @@ export class WS extends BaseWS {
opts.headers.cookie.push(`${name}=${cookie.value}`);
}
}
return new WebSocket(uri, protocols, opts);
return new ws.WebSocket(uri, protocols, opts);
}

doWrite(packet: Packet, data: RawData) {
Expand Down

0 comments on commit 7fcddcb

Please sign in to comment.