Handle BigInt
errors when bundling js-math-tools
in Vite
Transpilation fails when bundling js-math-tools
with Vite because the library uses BigInt
in some of its calculations. To fix this, add these settings to the vite.config.js
file:
module.exports = {
build: {
target: "es2020",
},
optimizeDeps: {
esbuildOptions: {
target: "es2020",
},
},
}
Since this solution was actually found in the SvelteKit GitHub repo's issues list, it may be the case that this solution will work for other bundlers, perhaps with minimal tweaks.