Javascript 如何在IE11中正确使用babel/webpack/corejs3进行捆绑?
当前,输出导致IE11中出现脚本语法错误。(SCRIPT1002:语法错误) 我的网页设置如下Javascript 如何在IE11中正确使用babel/webpack/corejs3进行捆绑?,javascript,webpack,babeljs,babel-polyfill,Javascript,Webpack,Babeljs,Babel Polyfill,当前,输出导致IE11中出现脚本语法错误。(SCRIPT1002:语法错误) 我的网页设置如下 const path = require("path"); module.exports = { mode: "none", entry: ["core-js/stable", "./src/js/index.js"], output: { path: path.resolve(_
const path = require("path");
module.exports = {
mode: "none",
entry: ["core-js/stable", "./src/js/index.js"],
output: {
path: path.resolve(__dirname + "/dist"),
filename: "bundle.js",
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: [[
"@babel/preset-env",{
"useBuiltIns": "usage",
"corejs" : {
version : "3",
proposals : true
},
"targets" : {
"browsers": ["last 3 versions", "ie >= 11"],
"node": "current"
}
}
]],
plugins: ["@babel/transform-runtime"]
}
}
}
]
},
// devtool: "eval-source-map"
}
{
"name": "amp-test",
"version": "1.0.0",
"description": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "babel src/js -d src",
"webpack-build": "webpack"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.3",
"@babel/plugin-transform-runtime": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"@babel/runtime": "^7.12.1",
"babel-loader": "^8.1.0",
"webpack": "^5.2.0",
"webpack-cli": "^4.1.0"
},
"dependencies": {
"core-js": "^3.6.5"
}
}
我的模块依赖性如下
const path = require("path");
module.exports = {
mode: "none",
entry: ["core-js/stable", "./src/js/index.js"],
output: {
path: path.resolve(__dirname + "/dist"),
filename: "bundle.js",
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: [[
"@babel/preset-env",{
"useBuiltIns": "usage",
"corejs" : {
version : "3",
proposals : true
},
"targets" : {
"browsers": ["last 3 versions", "ie >= 11"],
"node": "current"
}
}
]],
plugins: ["@babel/transform-runtime"]
}
}
}
]
},
// devtool: "eval-source-map"
}
{
"name": "amp-test",
"version": "1.0.0",
"description": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "babel src/js -d src",
"webpack-build": "webpack"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.3",
"@babel/plugin-transform-runtime": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"@babel/runtime": "^7.12.1",
"babel-loader": "^8.1.0",
"webpack": "^5.2.0",
"webpack-cli": "^4.1.0"
},
"dependencies": {
"core-js": "^3.6.5"
}
}
我一直在寻找类似的问题并尝试,但我仍然没有得到我想要的结果()
如果您查看上面的捆绑输出,您可以看到webpack引导从一个箭头函数开始。
我不知道为什么地狱会变成一个箭头函数。
我迫切需要专家的帮助
js bundled in the index.html file
<script src="./dist/bundle.js" defer></script>
It is imported and used in the above format.
For reference, it is not SPA, you can think of it as a static web.
js捆绑在index.html文件中
它以上述格式导入和使用。
作为参考,它不是SPA,您可以将其视为一个静态web。
多谢各位