Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failed for: "ERROR: Big integer literals are not available in the configured target environment" with Ionic + React + Vite #1745

Closed
lags opened this issue Nov 23, 2023 · 7 comments

Comments

@lags
Copy link

lags commented Nov 23, 2023

When try to launch yarn build build stuck with error.

rendering chunks (9)...
[vite:esbuild-transpile] Transform failed with 4 errors:
assets/index-!~{001}~.js:13263:5712: ERROR: Big integer literals are not available in the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari12" + 3 overrides)
assets/index-!~{001}~.js:13263:5716: ERROR: Big integer literals are not available in the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari12" + 3 overrides)
assets/index-!~{001}~.js:13263:5725: ERROR: Big integer literals are not available in the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari12" + 3 overrides)
assets/index-!~{001}~.js:13263:5729: ERROR: Big integer literals are not available in the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari12" + 3 overrides)

Big integer literals are not available in the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari12" + 3 overrides)
...more log error...

For reproduce I use:
ionic start photo-gallery tabs --type=react --capacitor
cd photo-gallery
npm install mqtt --save

Inside App.tsx:
import mqtt from 'mqtt';
and in useEffect hook:

useEffect(() => {
  const _mqtt = mqtt.connect({});
}, []);

If I remove or comment const _mqtt = mqtt.connect({}); build successfully

As workaround I am using mqtt library throught cdn (putting script tag inside index.html) and call by window.mqtt.connect({})

Any suggest for fix it is appreciate

@lags
Copy link
Author

lags commented Nov 24, 2023

I just tried but the error is same

@lags
Copy link
Author

lags commented Nov 24, 2023

I solved disabled legacy plugin edit config with:

export default defineConfig({
    ....
    build: {
        target: ['esnext']
    },
    plugins: [
      ....
      legacy({
        renderLegacyChunks: false,
      }),
      ....
    ],
    ....
});

@lags lags closed this as completed Nov 24, 2023
@LiuZiqi-dual
Copy link

By the way, in addition to adding the configuration mentioned by @lags above, I also had to add the following configuration for it to run correctly.

vite.config.ts

    optimizeDeps: {
      ......
      esbuildOptions: {
        target: "esnext", 
        // Node.js global to browser globalThis
        define: {
          global: 'globalThis'
        },
        supported: { 
          bigint: true 
        },
      }
    },

@robertsLando
Copy link
Member

I don't need to add any of that setting when using with vite, are you using latest?

@jdutchak
Copy link

life saver

@robertsLando
Copy link
Member

The workaround should not be needed anymore after this is merged: #1963

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants