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

Legacy plugin breaks async generators #11835

Closed
7 tasks done
Pinpickle opened this issue Jan 28, 2023 · 2 comments · Fixed by #11896
Closed
7 tasks done

Legacy plugin breaks async generators #11835

Pinpickle opened this issue Jan 28, 2023 · 2 comments · Fixed by #11896
Labels
enhancement New feature or request plugin: legacy

Comments

@Pinpickle
Copy link

Describe the bug

I recently upgraded from Vite 2.x to Vite 4.x, and I can no longer build my project. I think it's due to plugin-legacy changing the target browsers here:

config.build.target = [
'es2020',
'edge79',
'firefox67',
'chrome64',
'safari11.1',

This target leads esbuild to think it needs to transpile async generators (which was usually left to babel). When I run build, it throws this error (from transpiling a dependency): Transforming async generator functions to the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari11.1" + 2 overrides) is not supported yet

Reproduction

https://stackblitz.com/edit/vitejs-vite-wddogq

Steps to reproduce

Run npm install and then npm run build

System Info

success Install finished in 1.172s


  System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 7.17.0 - /usr/local/bin/npm
  npmPackages:
    @vitejs/plugin-legacy: ^3.0.2 => 3.0.2 
    vite: ^4.1.0-beta.1 => 4.1.0-beta.1

Used Package Manager

npm

Logs

Click to expand!
❯ npm run build
$ vite build
vite v4.1.0-beta.1 building for production...
✓ 6 modules transformed.
dist/assets/index-legacy-6515cddc.js      2.17 kB │ gzip: 1.13 kB
dist/assets/polyfills-legacy-40963d34.js  7.92 kB │ gzip: 3.11 kB
[vite:esbuild-transpile] Transform failed with 1 error:
assets/index-!~{001}~.js:61:0: ERROR: Transforming async generator functions to the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari11.1" + 2 overrides) is not supported yet

Transforming async generator functions to the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari11.1" + 2 overrides) is not supported yet
58 |    asyncGenerator();
59 |  }
60 |  
   |   ^
61 |  async function* asyncGenerator() {
   |  ^
62 |    yield 0;

error during build:
Error: Transform failed with 1 error:
assets/index-!~{001}~.js:61:0: ERROR: Transforming async generator functions to the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari11.1" + 2 overrides) is not supported yet
    at failureErrorWithLog (file:///home/projects/vitejs-vite-wddogq/node_modules/esbuild/lib/main.js:1594:15)
    at eval (file:///home/projects/vitejs-vite-wddogq/node_modules/esbuild/lib/main.js:827:29)
    at responseCallbacks.<computed> (file:///home/projects/vitejs-vite-wddogq/node_modules/esbuild/lib/main.js:691:9)
    at handleIncomingPacket (file:///home/projects/vitejs-vite-wddogq/node_modules/esbuild/lib/main.js:746:9)
    at Socket.readFromStdout (file:///home/projects/vitejs-vite-wddogq/node_modules/esbuild/lib/main.js:667:7)
    at EventEmitter.emit (https://vitejsvitewddogq-ogu5.w-corp.staticblitz.com/blitz.685d3c93544a5e80be2c9e6906d68c0f4bd854cc.js:6:155574)
    at addChunk (https://vitejsvitewddogq-ogu5.w-corp.staticblitz.com/blitz.685d3c93544a5e80be2c9e6906d68c0f4bd854cc.js:6:656481)
    at readableAddChunk (https://vitejsvitewddogq-ogu5.w-corp.staticblitz.com/blitz.685d3c93544a5e80be2c9e6906d68c0f4bd854cc.js:6:656185)
    at Readable.push (https://vitejsvitewddogq-ogu5.w-corp.staticblitz.com/blitz.685d3c93544a5e80be2c9e6906d68c0f4bd854cc.js:6:656869)
    at _0x5baa5a.onStreamRead [as onread] (https://vitejsvitewddogq-ogu5.w-corp.staticblitz.com/blitz.685d3c93544a5e80be2c9e6906d68c0f4bd854cc.js:6:783983)
    at Object.emit (https://vitejsvitewddogq-ogu5.w-corp.staticblitz.com/blitz.685d3c93544a5e80be2c9e6906d68c0f4bd854cc.js:8:250102)
    at _0x555c73 (https://vitejsvitewddogq-ogu5.w-corp.staticblitz.com/blitz.685d3c93544a5e80be2c9e6906d68c0f4bd854cc.js:8:251737)
    at Object._0xecd3d [as emit] (https://vitejsvitewddogq-ogu5.w-corp.staticblitz.com/blitz.685d3c93544a5e80be2c9e6906d68c0f4bd854cc.js:8:248385)
    at https://vitejsvitewddogq-ogu5.w-corp.staticblitz.com/blitz.685d3c93544a5e80be2c9e6906d68c0f4bd854cc.js:8:250999
    at Map.forEach (<anonymous>)
    at _0x55861a (https://vitejsvitewddogq-ogu5.w-corp.staticblitz.com/blitz.685d3c93544a5e80be2c9e6906d68c0f4bd854cc.js:8:250970)

Validations

@sapphi-red
Copy link
Member

Unfortunately this is a current limitation of plugin-legacy. This requires #6922 to be implemented to plugin-legacy or async generator transpilation supported by esbuild (evanw/esbuild#2780)

Closing as a duplicate of #6922.

This target leads esbuild to think it needs to transpile async generators (which was usually left to babel).

Previously async generators were transpiled by babel for legacy build. But wasn't transpiled for modern build. This means when accessing with browsers that supports dynamic import but doesn't support async generators your site didn't work. See #10052 (comment), #10072 for more details.

@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale Jan 28, 2023
@sapphi-red sapphi-red added duplicate This issue or pull request already exists and removed pending triage labels Jan 28, 2023
@sapphi-red
Copy link
Member

I noticed that plugin-legacy could transpile async generators with babel for modern build.

@sapphi-red sapphi-red reopened this Jan 28, 2023
@sapphi-red sapphi-red added enhancement New feature or request plugin: legacy and removed duplicate This issue or pull request already exists labels Jan 28, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request plugin: legacy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants