Purecloud-platform-client-v2 version 163.0.0 “require is not defined” react + vite

I'm using the javascript SDK "purecloud-platform-client-v2" version 163.0.0.
We have a react/typescript application using Vite as the build tool.

Uncaught ReferenceError: require is not defined
at index-d8982823.js:86:861952
const Ice = require("debounce-promise")

Please advise, how to fix the issue...
I works in dev build, but fails in prod build...

Hi,

I can't find anywhere in the javascript SDK, where debounce-promise is used. Are you using any other packages in your project that might be using that dependency? From personal experience though, that issue is sometimes fixed by adding polyfills to your project. See this forum thread for advice on a possible fix using polyfill.

Regards,
Declan

Thanks for the feedback, I managed to find the require comes from the lib: genesys-cloud-streaming-client, which is referenced by the genesys-cloud-webrtc-sdk...

If I remove the genesys-cloud-webrtc-sdk package, then the build works as expected.
I have already added and configured the vite-plugin-node-polyfills, but this does not solve the issue...
Can you please use the same solution to fix the issue in genesys-cloud-streaming-client, what you have used in the Javascript SDK, version 163.0.0 to fix the similar issue?

King Regards,
John

Or do you have any other idea please, how to resolve the issue?

Hi John,

See here for details on using the webRTC SDK.

As for using the same solution we used for version 163.0.0 of the javascript SDK, that most likely will not be possible. In the case of the javascript SDK we were lucky that we were able to find a solution without having to do a major rewrite of the SDK. It is unlikely we will be as lucky with the webRTC SDK without having to completely rebuild it from the ground up to no longer use builtin node modules.

Regards,
Declan

Thanks Declan, this makes a sense.
I managed to solve the issue using your suggested workaround...

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.