OpenVidu / openvidu

OpenVidu Platform main repository
https://openvidu.io
Apache License 2.0
1.87k stars 463 forks source link

Openvidu-browser gave an error when building with vite #768

Closed InSooBae closed 1 year ago

InSooBae commented 1 year ago

Describe the bug

I am using openvidu-browser 2.24.0 with vue 3.2.37 + vite 2.9.14.
There is some problem when it build by vite.
(Works fine when run locally)

image

Expected behavior

I guess viteis always build strict-mode, so some files(in KurentoUtils/**) are giving errors.

It seems difficult to solve the problem with vite. Because Vite cannot handle and does not support code that only runs on non-strict mode (sloppy mode). This is because Vite uses ESM and it is always strict mode inside ESM.

image

So I think we should make openvidu-browser build without problems in strict mode.

before build

image

after build

image

The reason for the error is that there is a problem with the default binding in strict-mode.

If you don't think you can solve this error, you should specify that it conflicts with vite.

jrmi commented 1 year ago

Since I've switched to vitejs I'm not able to use openvidu neither, I have a similar error:

image

while in dev it's working perfectly...

Do you plan to make your openvidu-browser compatible with vitejs?

jrmi commented 1 year ago

If someone experience the same problem I have solved it by not bundling the openvidu library with vite but I include it from a CDN and it works.

InSooBae commented 1 year ago

If someone experience the same problem I have solved it by not bundling the openvidu library with vite but I include it from a CDN and it works.

Alternatively, try "npm run build --no-strict" to avoid "strict mode" https://rollupjs.org/configuration-options/#output-strict

CSantosM commented 1 year ago

Hi, could you please give me access to a Vue + Vite sample project and the steps that I should follow for reproducing this issue?

jrmi commented 1 year ago

By updating the vitejs framework the the latest version (from 2.2.x->4.3.x), it also solves the problem, may be it's not worth to try to solve it for old vite version...

bum19 commented 7 months ago

If someone experience the same problem I have solved it by not bundling the openvidu library with vite but I include it from a CDN and it works.

how can i get openvidu-cdn url?

jrmi commented 7 months ago

If someone experience the same problem I have solved it by not bundling the openvidu library with vite but I include it from a CDN and it works.

how can i get openvidu-cdn url?

Last time I searched "Openvidu cdn" with my search engine. You can found something like: https://www.jsdelivr.com/package/npm/openvidu-browser