vite-plugin-legacy
vite-plugin-legacy copied to clipboard
error in ie11
Unhandled promise rejection TypeError: strict 模式下不允许访问函数或参数对象的“caller”属性
code:
legacy({ targets: [ 'ie >= 11' ] })
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.
dome: https://github.com/yexiaodong/vite-ie
error in ie
Unhandled promise rejection Error: assets/index-legacy.0b779598.js
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
Unhandled promise rejection TypeError: strict 模式下不允许访问函数或参数对象的“caller”属性
code:
legacy({ targets: [ 'ie >= 11' ] })
same problem
same too
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?
same problem,is there a solution?
this is my config
plugins: [
vue(),
legacy({
targets: ["ie 11"],
additionalLegacyPolyfills: ["regenerator-runtime/runtime"],
}),
],
same problem,is there a solution?
same problem on chrome <= 40
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
is this a bug?
same problem
same problem
any updates? have probably the same issue if trying to compile for Chrome < 50
same probolems here , looks like it is becasue vue3 not support ie 11
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"
}
}
We're getting a similar same thing for a Vite React project.
Encountered the same problem. Any idea how to fix it ?
Same here:
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']
})
],
})
I think vue3 will never be running on ie11 - at least it is not planned.
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.