Open knichwitz opened 3 months ago
Hi @knichwitz,
From what you're mentioning, global
object doesn't exist in vite.js
and instead it is renamed to globalThis
?
If so, some ideas to resolve:
this.websocket = new (global.WebSocket || globalThis.WebSocket || require('ws'))(signedURL);
this.websocket = new (WebSocket || require('ws'))(signedURL);
Please let us know if these fix the issue you are seeing, and we can get a PR merged in to resolve this.
Hi @sirknightj,
thank you for your swift reply!
The second solution will fix the issue with vite.js
this.websocket = new (WebSocket || require('ws'))(signedURL);
This change breaks the dev environment of any developer using vite instead of webpack.
https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-js/blob/de209884fcd388c3fea4937a5b99354ef9519af3/src/SignalingClient.ts#L151
Workaround in
vite.config.ts
:define: { "global": "globalThis" }