babel 7,IE> 9,webpack 3,ES6的IE语法错误

时间:2018-10-03 11:09:48

标签: javascript webpack babel babel-polyfill

我什至无法获得箭头功能,

()=> 1 * 1;可以使用Babel 7在IE 9和IE 11中工作,它可以在Chrome中使用chrome,rest和destructure,但在IE 9或IE 11中,以下功能则无法使用,箭头功能,解构,休息。

代码设置如下:

package.json文件:

devDependencies:
        "@babel/cli": "^7.1.0",
        "@babel/core": "^7.0.0",
        "@babel/preset-env": "^7.1.0",
        "@babel/preset-react": "^7.0.0",
        "@babel/preset-stage-0": "^7.0.0",
        "@babel/preset-stage-3": "^7.0.0",
        "babel-loader": "^8.0.0",

dependencies: 
"@babel/polyfill": "^7.0.0"


Running with webpack 3.8.1.

.babelrc file is simply:

{
"presets":  [
    ["@babel/preset-env", {
        "targets": {
            "browsers": ["ie >= 9"]
        },
        "esmodules": true,
        "loose": true,
        "debug": true,
        "useBuiltIns": "entry"
    }],
    "@babel/preset-stage-0"],
"plugins": [
    "@babel/plugin-transform-runtime",
    "@babel/plugin-syntax-dynamic-import",
    "@babel/plugin-syntax-import-meta",
    "@babel/plugin-transform-arrow-functions",
    "@babel/plugin-transform-object-assign",
    "@babel/plugin-syntax-dynamic-import",
    "@babel/plugin-proposal-class-properties",
    "@babel/plugin-proposal-json-strings"
],
"ignore": [
    "node_modules"
]
}

webpack.js文件:

进入webpack.js:

entry: {
        commonThirdParty: ['@babel/polyfill', 'backbone', 'lodash'],
},

module: {
    loaders: [{
                    test: /.js?$/,
                    include: odfPath,
                    exclude: /(node_modules|node)/,
                    use: [{
                        loader: 'babel-loader',
                    }]
    }]
}

任何人都没有任何想法,我如何才能使IE 9和IE 11接受转译到ES5的ES6代码以成功工作?

0 个答案:

没有答案