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

"TypeError: undefined is not a function at System.register.execute" in chrome 39 #17405

Closed
7 tasks done
oyster0118 opened this issue Jun 6, 2024 · 5 comments
Closed
7 tasks done
Labels
invalid This doesn't seem right plugin: legacy

Comments

@oyster0118
Copy link

oyster0118 commented Jun 6, 2024

Describe the bug

"TypeError: undefined is not a function
    at System.register.execute (https://XXX/assets/index-legacy-4ace9b4e.js:28:31225)
    at n (https://XXX/assets/polyfills-legacy-05ebab4a.js:1:57039)
    at v (https://XXX/assets/polyfills-legacy-05ebab4a.js:1:57413)
    at https://XXX/assets/polyfills-legacy-05ebab4a.js:1:56952
    at nl (https://XXX/assets/polyfills-legacy-05ebab4a.js:1:24256)
    at https://XXX/assets/polyfills-legacy-05ebab4a.js:1:24487
    at MutationObserver.Jf (https://XXX/assets/polyfills-legacy-05ebab4a.js:1:22200)"

vite.config.ts

import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import { VantResolver } from '@vant/auto-import-resolver'
import legacy from '@vitejs/plugin-legacy'

// https://vitejs.dev/config/
export default defineConfig({
  base:'/xx',
  plugins: [
    vue(),
    Components({
      resolvers: [VantResolver()],
    }),
    legacy({
      targets: ['defaults', 'android >= 4.4', 'chrome >= 39'],
      additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
      renderLegacyChunks: true,
      polyfills:[
        'es.symbol',
        'es.array.filter',
        'es.promise',
        'es/reflect',
        'es.promise.finally',
        'es/map',
        'es/set',
        'es.array.for-each',
        'es.object.define-properties',
        'es.object.define-property',
        'es.object.get-own-property-descriptor',
        'es.object.get-own-property-descriptors',
        'es.object.keys',
        'es.object.to-string',
        'web.dom-collections.for-each',
        'esnext.global-this',
        'esnext.string.match-all'
      ]
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
    port: 8080,
    proxy: {
      '/xxxt': {
        target: 'https://XXX.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/XX/, 'XX')
      }
    },
  }
})

Reproduction

https://stackblitz.com/edit/vitejs-vite-fdnmkt?file=vite.config.ts,package.json,index.html&terminal=dev

Steps to reproduce

No response

System Info

System:
    OS: Windows 10 10.0.17763
    CPU: (4) x64 Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
    Memory: 1.96 GB / 7.44 GB
  Binaries:
    Node: 18.16.1 - C:\Program Files\nodejs\node.EXE
    npm: 9.5.1 - ~\AppData\Roaming\npm\npm.CMD
    pnpm: 7.25.0 - ~\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Chrome: 125.0.6422.141(39.0.0.0)
    Internet Explorer: 11.0.17763.1
  npmPackages:
    @vitejs/plugin-legacy: ^4.1.1 => 4.1.1
    @vitejs/plugin-vue: ^4.4.0 => 4.4.0
    vite: ^4.4.11 => 4.5.0

Used Package Manager

npm

Logs

No response

Validations

Copy link

stackblitz bot commented Jun 6, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@bluwy
Copy link
Member

bluwy commented Jun 6, 2024

The repro given doesn't match the bug and setup you're describing. I can't replicate it locally. Can you update with a new repro link?

I'd also suggest minimizing the Vite plugins used and dependencies to narrow down what's causing it. From the error, it seems like System.register.execute is called before System.register is initialized by systemjs.

Copy link

github-actions bot commented Jun 6, 2024

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

@oyster0118
Copy link
Author

The repro given doesn't match the bug and setup you're describing. I can't replicate it locally. Can you update with a new repro link?

I'd also suggest minimizing the Vite plugins used and dependencies to narrow down what's causing it. From the error, it seems like System.register.execute is called before System.register is initialized by systemjs.

I just updated the link to reproduce the issue. In addition, I have a question: can the Vue3 application built by Vite be compatible with Chrome version 39?

@sapphi-red
Copy link
Member

The error is happening because you didn't add the polyfill for Object.assign. If you add es.object.assign to polyfills, the undefined is not a function error disappears. But a different error (ReferenceError: Proxy is not defined) would be shown.

This is because Vue 3 doesn't support Chrome 39.
https://vuejs.org/about/faq.html#what-browsers-does-vue-support

Closing as it's not a bug in Vite nor plugin-legacy.

@sapphi-red sapphi-red added the invalid This doesn't seem right label Jun 17, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jul 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
invalid This doesn't seem right plugin: legacy
Projects
None yet
Development

No branches or pull requests

3 participants