vite-plugin-legacy icon indicating copy to clipboard operation
vite-plugin-legacy copied to clipboard

error in ie11

Open yexiaodong opened this issue 4 years ago • 21 comments

Unhandled promise rejection TypeError: strict 模式下不允许访问函数或参数对象的“caller”属性

code: legacy({ targets: [ 'ie >= 11' ] })

yexiaodong avatar Feb 23 '21 15:02 yexiaodong

I don't have a machine that can run IE 11, so you're on your own.

Consider providing example code that produces the same error, so others can maybe help you.

aleclarson avatar Feb 23 '21 20:02 aleclarson

dome: https://github.com/yexiaodong/vite-ie error in ie Unhandled promise rejection Error: assets/index-legacy.0b779598.js

yexiaodong avatar Feb 24 '21 14:02 yexiaodong

Unhandled promise rejection TypeError: strict 模式下不允许访问函数或参数对象的“caller”属性

code: legacy({ targets: [ 'ie >= 11' ] })

@yexiaodong used with vue3,encountered same problem, how is it going ? I tried to delete the declaration of "use strict ", the error in console changed to 'Unhandled promise rejection ReferenceError: “Proxy”未定义', I also found the Proxy can't be polyfilled with polyfill.io, so i thought vite and vue3 can not work well with IE11

use vite and vue2,with this plugin ,haven't found the problem

xcchcaptain avatar Mar 02 '21 08:03 xcchcaptain

Unhandled promise rejection TypeError: strict 模式下不允许访问函数或参数对象的“caller”属性

code: legacy({ targets: [ 'ie >= 11' ] })

same problem

Leonvanx avatar Mar 24 '21 15:03 Leonvanx

same too

gentlecoder avatar Mar 25 '21 07:03 gentlecoder

I'm having a similar problem with IE 11 except that I'm getting Unhandled promise rejection undefined. I've found a hackish workaround, at least for me. I'm using svelte. Put this into the file that is giving you the error (any where inside the

new Promise(() => {})

Of course I have no idea why this works but I suspect it has to do with the auto detection of polyfills. Maybe someone more knowledgeable might have a more elegant fix?

seanthingee avatar Apr 16 '21 14:04 seanthingee

same problem,is there a solution?

this is my config

plugins: [
    vue(),
    legacy({
      targets: ["ie 11"],
      additionalLegacyPolyfills: ["regenerator-runtime/runtime"],
    }),
  ],

MaomaoFE avatar Jun 02 '21 03:06 MaomaoFE

same problem,is there a solution?

Daschmi avatar Jun 17 '21 11:06 Daschmi

same problem on chrome <= 40

yuyu775 avatar Aug 07 '21 14:08 yuyu775

In some browsers eg: old safari webview, Object.getOwnPropertyNames will return key 'caller', this will cause code throw error

new Set(Object.getOwnPropertyNames(Symbol).map(key => Symbol[key]).filter(item => typeof item === 'symbol'))

in strict mode, some browsers will get caller and access Symbol.caller, which will throw TypeError.

Symbol.caller
// VM74:1 Uncaught TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at <anonymous>:1:8

CYYSILVER avatar Aug 09 '21 13:08 CYYSILVER

is this a bug?

liho98 avatar Aug 11 '21 03:08 liho98

same problem

babyzone2004 avatar Sep 22 '21 10:09 babyzone2004

same problem

Tomas2D avatar Sep 23 '21 19:09 Tomas2D

any updates? have probably the same issue if trying to compile for Chrome < 50

bublikOff avatar Oct 11 '21 18:10 bublikOff

same probolems here , looks like it is becasue vue3 not support ie 11

alvc666 avatar Oct 20 '21 11:10 alvc666

With a vue 2.6 I resolved this problem IE11 Unhandled promise rejection Error by using the module naming syntax for my component files.

i.e. hello.module.js

This Vue setup works fine with all browser including IE11

- src
  - components
    hello.module.js
    index.js
main.js

In main.js :

import '/src/style.css'
import Vue from 'vue/dist/vue.js';
import { hello } from './src/components'

  new Vue({
    el: '#app',
    components: {
      hello
    }
  })

components/hello.module.js :

export const hello = {  
    name: 'Hello',
    template: `<h1>Hello World</h1>`,
    mounted() {
        this.message();
    },
    methods: {
        message() {
            console.log('Hello World from console');
        }
    }
}

components/index.js

export * from './hello.module'

vite.config.js :

import legacy from '@vitejs/plugin-legacy'

export default {
  plugins: [
    legacy({
      targets: ['ie >= 11'],
      additionalLegacyPolyfills: ['regenerator-runtime/runtime']
    })
  ]
}

package.json :

{
  "name": "vanilla",
  "version": "0.0.0",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "preview": "vite preview"
  },
  "devDependencies": {
    "@vitejs/plugin-legacy": "^1.6.4",
    "vite": "^2.7.2"
  },
  "dependencies": {
    "vue": "^2.6.14"
  }
}

bourpie avatar Jan 23 '22 17:01 bourpie

We're getting a similar same thing for a Vite React project. image

gla23 avatar Jan 28 '22 17:01 gla23

Encountered the same problem. Any idea how to fix it ?

cpietsch avatar Feb 02 '22 13:02 cpietsch

Same here: Bildschirmfoto 2022-02-11 um 14 00 12

Basically just building the unchanged vue3-ts scaffold project with:

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

// https://vitejs.dev/config/
export default defineConfig({
  base: "/some-other-path/",
  plugins: [
      vue(),
      legacy({
        targets: ['defaults', 'ie >= 11'],
        additionalLegacyPolyfills: ['regenerator-runtime/runtime']
      })
  ],
})

ludwig-gramberg avatar Feb 11 '22 13:02 ludwig-gramberg

I think vue3 will never be running on ie11 - at least it is not planned.

cpietsch avatar Feb 11 '22 15:02 cpietsch

For us the solution was to look into the exact line and column that the error occurs and debug from there. We found out that an update in react-pdf didn't work in IE. It's unlikely that your are having the same issue, but if you look into the exact row and column you might be able to work backwards.

gla23 avatar Feb 12 '22 15:02 gla23