cookpete / react-player

A React component for playing a variety of URLs, including file paths, YouTube, Facebook, Twitch, SoundCloud, Streamable, Vimeo, Wistia and DailyMotion
https://cookpete.github.io/react-player
MIT License
8.9k stars 1.12k forks source link

React-player error when minified #1746

Open saidelimam opened 2 months ago

saidelimam commented 2 months ago

here's the error:

Unexpected Application Error! Minified React error #130; visit https://reactjs.org/docs/error-decoder.html?invariant=130&args[]=object&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings. Error: Minified React error #130; visit https://reactjs.org/docs/error-decoder.html?invariant=130&args[]=object&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.

My Vite minify config:

minify: 'terser',
terserOptions: {
compress: {
    drop_console: isProduction && !isPreview,
    drop_debugger: true, 
    passes: 3, 
    reduce_funcs: true,
    reduce_vars: true, 
},
format: {
    comments: false, 
    wrap_iife: true,
},
mangle: {
    properties: {
        regex: /^_/, // 
    },
},
ecma: 2020,
module: true,
toplevel: true,
safari10: true,
},
saidelimam commented 2 months ago

It looks like it's related to CJS module export on a ESModule Vite project. Is there a chance to have an ESM package of react-player?

thdebay commented 2 months ago

Which version of Vite are you using? I had the same issue with Vite v2, upgrading to v3 seems to have solved the issue for me.

saidelimam commented 2 months ago

Which version of Vite are you using? I had the same issue with Vite v2, upgrading to v3 seems to have solved the issue for me.

I'm on Vite version 5.0.11

floodofstatic commented 2 months ago

I also had this problem come up recently (Vite v3).

Downgrading react-player from 2.14.1 to 2.13.0, the most recent previous version we had installed (upgrading seems to be the point where it stopped working) has resolved it.

Not sure if using 2.15.x will fix it, but don't have the time to test right now.

luwes commented 2 months ago

could you provide a Codesandbox reproduction online? that will make it easier to debug. thank you!

LydiaF commented 1 month ago

Downgrading from 2.16 to 2.13 worked with Vite for us with this error:

error during build: Error: [commonjs--resolver] invalid import "import( / webpackIgnore: true / ${sdkUrl} )". It cannot be statically analyzed. Variable dynamic imports must start with ./ and be limited to a specific directory. For example: import(./foo/${bar}.js). file: /Users/lydia/code/elka/csvite/node_modules/react-player/lib/players/Mux.js

luwes commented 3 weeks ago

try v3.0.0-canary.3, let me know if it works https://www.npmjs.com/package/react-player/v/3.0.0-canary.3 https://codesandbox.io/p/devbox/react-player-vite-6n78q7