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

Vite Plugin Legacy unable to build BigInt #17392

Closed
7 tasks done
jwcooper opened this issue Jun 4, 2024 · 2 comments
Closed
7 tasks done

Vite Plugin Legacy unable to build BigInt #17392

jwcooper opened this issue Jun 4, 2024 · 2 comments

Comments

@jwcooper
Copy link

jwcooper commented Jun 4, 2024

Describe the bug

Using defaults, vite plugin legacy errors out on a statement such as console.log(123n)

console.log(BigInt(123)) works just fine.

Reproduction

https://github.com/jwcooper/vite-bigint

Steps to reproduce

Run npm install followed by npm run build

System Info

System:
    OS: Linux 6.8 Fedora Linux 40 (Workstation Edition)
    CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
    Memory: 15.76 GB / 31.25 GB
    Container: Yes
    Shell: 5.2.26 - /bin/bash
  Binaries:
    Node: 20.11.0 - ~/.asdf/installs/nodejs/20.11.0/bin/node
    Yarn: 1.22.21 - ~/.asdf/installs/nodejs/20.11.0/bin/yarn
    npm: 10.4.0 - ~/.asdf/plugins/nodejs/shims/npm
  Browsers:
    Chrome: 127.0.6510.4
  npmPackages:
    @vitejs/plugin-legacy: ^5.4.1 => 5.4.1 
    @vitejs/plugin-vue: ^5.0.4 => 5.0.5 
    vite: ^5.2.0 => 5.2.12

Used Package Manager

npm

Logs

> [email protected] build                                                                                                                                                      
> vite build                                                                                                                                                              
                                                                                                                                                                          
vite v5.2.12 building for production...                                                                                                                                   
✓ 16 modules transformed.                                                                                                                                                 
dist/assets/index-legacy-4yahLsja.js      67.23 kB │ gzip: 24.37 kB                                                                                                       
dist/assets/polyfills-legacy-Lh3Ygw8X.js  79.60 kB │ gzip: 32.16 kB                                                                                                       
x Build failed in 3.94s                                                                                                                                                   
error during build:                                                                                                                                                       
[vite:esbuild-transpile] Transform failed with 1 error:                                                                                                                   
assets/index-!~{001}~.js:5726:12: ERROR: Big integer literals are not available in the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari
12" + 2 overrides)                                                                                                                                                        
                                                                                                                                                                          
Big integer literals are not available in the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari12" + 2 overrides)                       
5724|  const App = /*#__PURE__*/_export_sfc(_sfc_main, [['__scopeId',"data-v-d6420450"]]);                                                                                
5725|                                                                                                                                                                     
5726|  console.log(123n);                                                                                                                                                 
   |              ^                                                                                                                                                       
5727|  
5728|  createApp(App).mount('#app');

    at failureErrorWithLog (/home/jwcooper/dev/tmp/bigint/node_modules/esbuild/lib/main.js:1651:15)
    at /home/jwcooper/dev/tmp/bigint/node_modules/esbuild/lib/main.js:849:29
    at responseCallbacks.<computed> (/home/jwcooper/dev/tmp/bigint/node_modules/esbuild/lib/main.js:704:9)
    at handleIncomingPacket (/home/jwcooper/dev/tmp/bigint/node_modules/esbuild/lib/main.js:764:9)
    at Socket.readFromStdout (/home/jwcooper/dev/tmp/bigint/node_modules/esbuild/lib/main.js:680:7)
    at Socket.emit (node:events:518:28)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)

Validations

@btea
Copy link
Collaborator

btea commented Jun 5, 2024

It looks like esbuild reported an error. You may refer to this link. evanw/esbuild#732

@bluwy
Copy link
Member

bluwy commented Jun 5, 2024

Yeah I think this is expected. It's not possible to downlevel BigInt to be used in older browsers that don't support it. However, if you want to get the build passing you can configure this:

  esbuild: {
    supported: {
      bigint: true
    }
  }

So that esbuild will assume that bigint will be supported. However your site will not work when it runs the file that contains the BigInt syntax.

@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Jun 5, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jun 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants