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 bug with buildPolyfillChunk and const type variable #9618

Closed
7 tasks done
Nepo92 opened this issue Aug 11, 2022 · 7 comments · Fixed by #9635
Closed
7 tasks done

@vite/plugin-legacy bug with buildPolyfillChunk and const type variable #9618

Nepo92 opened this issue Aug 11, 2022 · 7 comments · Fixed by #9635
Labels
p5-urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority) plugin: legacy

Comments

@Nepo92
Copy link

Nepo92 commented Aug 11, 2022

Describe the bug

I try build my project with vite 3.

I use @vitejs/plugin-legacy for support old browsers.

my vite.config.js file is

import { resolve } from 'path';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import legacy from '@vitejs/plugin-legacy';

export default defineConfig({
  base: '/',
  build: {
    rollupOptions: {
      input: {
        main: resolve(__dirname, 'pages/index.html'),
        about: resolve(__dirname, 'pages/about/index.html'),
      },
    },
  },
  server: {
    port: 3000,
    host: '0.0.0.0',
    hrm: true,
  },
  plugins: [
    vue(),
    legacy({
      targets: ['defaults', 'not IE 11'],
    }),
  ],
});

I run script yarn build but i have a problem

System Info

error during build:
Error: Transform failed with 1 error:
assets/polyfills-legacy.a7649e24.js:2104:3312: ERROR: Transforming const to the configured target environment ("es5" + 2 overrides) is not supported yet
    at failureErrorWithLog (/Users/aleksandreremeev/1bit/bitrix-vite-template/node_modules/esbuild/lib/main.js:1624:15)
    at /Users/aleksandreremeev/1bit/bitrix-vite-template/node_modules/esbuild/lib/main.js:1413:29
    at /Users/aleksandreremeev/1bit/bitrix-vite-template/node_modules/esbuild/lib/main.js:678:9
    at handleIncomingPacket (/Users/aleksandreremeev/1bit/bitrix-vite-template/node_modules/esbuild/lib/main.js:775:9)
    at Socket.readFromStdout (/Users/aleksandreremeev/1bit/bitrix-vite-template/node_modules/esbuild/lib/main.js:644:7)
    at Socket.emit (events.js:400:28)
    at addChunk (internal/streams/readable.js:293:12)
    at readableAddChunk (internal/streams/readable.js:267:9)
    at Socket.Readable.push (internal/streams/readable.js:206:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)

Used Package Manager

yarn

Logs

No response

Validations

@github-actions
Copy link

Hello @Nepo92. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.

@inori1707
Copy link

I also encountered this problem, my project failed to build since yesterday. After looking into it I find that maybe cause by systemjs's 6.12.2 release. It include a "const" statement in "dist/s.min.js" which imported by @vite/plugin-legacy.

So we may need wait for its fix or use "resolution" or "overrides" field of package manager as a temporary workaround.
Maybe @vite/plugin-legacy should pin his dependencies version?

@shoyuf
Copy link

shoyuf commented Aug 11, 2022

I also encountered this problem, my project failed to build since yesterday. After looking into it I find that maybe cause by systemjs's 6.12.2 release. It include a "const" statement in "dist/s.min.js" which imported by @vite/plugin-legacy.

So we may need wait for its fix or use "resolution" or "overrides" field of package manager as a temporary workaround. Maybe @vite/plugin-legacy should pin his dependencies version?

i use systemjs@6.12.1, it's has same problem Actually, it's systemjs@6.12.2

@imindzzz
Copy link

use yarn create vite my-app --template react to create a new empty project that can reproduce the problem
just by default option

// vite.config.js
import legacy from '@vitejs/plugin-legacy'

export default {
  plugins: [
    legacy({
      targets: ['defaults', 'not IE 11']
    })
  ]
}

@shoyuf
Copy link

shoyuf commented Aug 11, 2022

I also encountered this problem, my project failed to build since yesterday. After looking into it I find that maybe cause by systemjs's 6.12.2 release. It include a "const" statement in "dist/s.min.js" which imported by @vite/plugin-legacy.
So we may need wait for its fix or use "resolution" or "overrides" field of package manager as a temporary workaround. Maybe @vite/plugin-legacy should pin his dependencies version?

i use systemjs@6.12.1, it's has same problem

I set externalSystemJS to true resolved this problem

@haoqunjiang
Copy link
Member

Can be reproduced by pnpm create vue@2 vite-issue-9618 --default

@haoqunjiang haoqunjiang added the p5-urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority) label Aug 11, 2022
@inori1707
Copy link

@patak-dev @bluwy Thanks for quick fix! But can you check if this fix will break the compatibility of es2015 unsupported browser. Since it skip the transform of polyfills chunk, it will left es2015 syntax to output

@github-actions github-actions bot locked and limited conversation to collaborators Aug 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p5-urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority) plugin: legacy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants