How do I configure Big Integer Support in vitejs build

Hi,

I am the developer of spacewalk-site.netlify.app. I am getting the following error when attempting to build a PR branch for deployment:

ERROR: Big integer literals are not available in the configured target environment (“chrome87”, “edge88”, “es2020”, “firefox78”, “safari13” + 2 overrides)

Here is the full log:
https://app.netlify.com/sites/spacewalk-site/deploys/63582cecd7a1af0008718467

This error relates to lack of support for Big Integer in the build. Here is my vitejs configuration file:

export default {
    esbuild: {
        target: "es2020"
    },

    optimizeDeps: {
        esbuildOptions : {
            target: "es2020"
        }
    }
}

This enables support for Big Integer. This work correctly when I run:
npm run dev

This fails, however, when I try to build. What am I missing in the configuration to enable Big Integer during build?

Thanks

Sounds like a Vite issue to me:

Hi Hrishikesh,

Yah, I dug into this and came up with a fix:

// vite.config.js
import { defineConfig } from "vite"

export default defineConfig({
    build: {
        target: 'es2020'
    },
    optimizeDeps: {
        esbuildOptions : {
            target: "es2020"
        }
    }

})

Not that different from what I already had. Hey, it works.

Cheers,
Doug

Thanks for coming back and letting us know! Happy building :rocket:

1 Like