petyosi / react-virtuoso

The most powerful virtual list component for React
https://virtuoso.dev
MIT License
5.25k stars 301 forks source link

Minification errors using Android Webview #755

Closed ripplezen closed 2 years ago

ripplezen commented 2 years ago

I have a situation where I am using an Android Webview inside a react native mobile app and the distributed minified code is throwing random errors but the non-minified code works fine.

When using vite with the esbuild minifier bundles the non-minified file and then minifies it and that also works fine. There is something the webview doesn't like about the distributed minified version.

The line giving me problems is this line:

offsetTree = offsetTree.slice(0, startIndex + 1)

where the offsetTree is undefined when it shouldn't be ONLY when bundling the minified version. I believe it is a carriage return/spacing issue busting out of an if statement. It works fine in the latest Chrome both desktop and mobile. Did NOT work on an older mobile Chrome. Have not tested it on IOS yet... Any help/suggestions would be appreciated. Thank you.

petyosi commented 2 years ago

Haven't seen something like this. Minification is done with microbundle. What you describe has quite a few moving parts. If the older chrome version is to blame, can you reproduce it with the site demos in Browserstack?

ripplezen commented 2 years ago

I was able to solve my issue by importing the non-es6 version directly. import { Virtuoso } from 'react-virtuoso/dist/index'; and it now bundles and works correctly in the webview.