From 7fcddcb3bbd236b46aa8fee6f4ce6c45afb7b03a Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Tue, 7 Jan 2025 01:53:32 -0800 Subject: [PATCH] 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; ``` --- packages/engine.io-client/lib/transports/websocket.node.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/engine.io-client/lib/transports/websocket.node.ts b/packages/engine.io-client/lib/transports/websocket.node.ts index 83777991c..c587cceb7 100644 --- a/packages/engine.io-client/lib/transports/websocket.node.ts +++ b/packages/engine.io-client/lib/transports/websocket.node.ts @@ -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"; @@ -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) {