Search code examples
angularbrowserbuild

Angular ng build error with optimization configuration


Since today I can't build my project using the staging build configuration:

"release/staging": {
  "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "1000kb",
                  "maximumError": "5mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "20kb",
                  "maximumError": "40kb"
                }
              ],
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.staging.ts"
                }
              ],
              "outputHashing": "all"
            },

With ng build --configuration release/staging I got this error:

Error: Optimization error [main.5d5b767d4ce2058c.js]: X [ERROR] Big integer literals are not available in the configured target environment ("chrome118.0", "edge117.0", "firefox119.0", "ios13.0", "safari13.0")

    main.5d5b767d4ce2058c.js:131503:26:
      131503 │               maxRange = (1n << 64n) - 1n;

First of all I thought it was a problem with a specific browser version that I target so I looked at my .browserlistrc file and try to replace last 5 version by 3 and the ng build command succeeded.

last 3 Chrome version
last 3 Firefox version
last 3 Edge major versions
last 3 Safari major versions
last 3 iOS major versions
Firefox ESR
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.

I don't understand why I have this issue right now and I think I'm not solving my issue by doing this and I should look at something else...


Solution

  • BigInt are only available from Safari 14 onwards.

    Current iOS version is 17, this is why changing to last 3, fixes your issue.