My @babel/preset-env
configuration is working fine except for IE11. When I run it in IE11 I get this error:
SCRIPT438: Object doesn't support property or method 'assign'
After googling the error I see I need to use babel/polyfill
, but it is deprecated and the suggestion is that you now use core-js
. For such a widely used tool the official documentation is lacking.
I followed other StackOverflow posts and came up with this solution, but still I get the error:
Package.json:
"devDependencies": {
"@babel/core": "^7.10.2",
"@babel/preset-env": "^7.10.2",
"babel-loader": "^8.1.0",
"core-js": "^3.6.5",
...
}
webpack.config:
{
test: /\.(js)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
// presets: ['@babel/preset-env'],
presets: [
[
"@babel/preset-env", {
"targets": {
"browsers": ["last 2 versions", "> 0.1%", "not dead", "ie >= 11"]
},
"useBuiltIns": "usage",
"corejs": 3
}
]
]
}
}
},
I don't have a babelrc
or browserlists
file as I want to keep it as minimalist as possible.
Why isn't this working and why do I continue to get this error:
function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}
SCRIPT438: Object doesn't support property or method 'assign'