BigInt error in React production build.
While developing your React app with @web3auth/modal, the application may work correctly in development mode but fail in production with the following error:
Uncaught TypeError: Cannot convert a BigInt value to a number
This happens because the production build relies on Browserslist to determine which browsers to target. If browser versions are not explicitly specified, the build uses the default Browserslist configuration, which may target environments that do not fully support BigInt. This mismatch can result in runtime errors in production.
You can resolve this issue by explicitly defining supported browser versions in your package.json file:
"browserslist": {
"production": [
"supports bigint",
"not dead",
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
By adding these lines, you are telling the JavaScript bundlers to use specific versions of the browsers for the production build. After adding the above lines, create the production build again and you should be good to go.