Skip to content

Commit 82c57c6

Browse files
authored
Use native WebSocket in server runtimes that support it (#2500)
* Use native `WebSocket` in server runtimes that support it * Create witty-camels-remember.md
1 parent c1ae0f1 commit 82c57c6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solana/ws-impl": patch
3+
---
4+
5+
Use native `WebSocket` for compatibility with server runtimes that support it, like Deno

packages/ws-impl/src/index.node.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// When building the browser bundle, this import gets replaced by `globalThis.WebSocket`.
22
import WebSocketImpl from 'ws';
33

4-
export default WebSocketImpl;
4+
export default globalThis.WebSocket
5+
? globalThis.WebSocket // Use native `WebSocket` in runtimes that support it (eg. Deno)
6+
: WebSocketImpl;

0 commit comments

Comments
 (0)