Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Webpack 巴贝尔用箭头函数创造生活_Webpack_Babeljs_Arrow Functions_Babel Loader - Fatal编程技术网

Webpack 巴贝尔用箭头函数创造生活

Webpack 巴贝尔用箭头函数创造生活,webpack,babeljs,arrow-functions,babel-loader,Webpack,Babeljs,Arrow Functions,Babel Loader,我正在尝试使用babel和webpack传输一个极其简单的文件: window.foo = function(bar) { return {...bar}; } 但是,输出(相当大)是 (为了简单起见,我使用了…来简单地缩短输出)。我的webpack.config.js如下所示: const path = require('path'); module.exports = { entry: './src/index.js', output: { pa

我正在尝试使用babel和webpack传输一个极其简单的文件:

window.foo = function(bar) {
    return {...bar};
}
但是,输出(相当大)是

(为了简单起见,我使用了
来简单地缩短输出)。我的
webpack.config.js
如下所示:

const path = require('path'); 

module.exports = {
    entry: './src/index.js',
    output: {
        path: path.resolve(__dirname, 'out/'),
        filename: 'index.js'
    },
    module: {
        rules: [
            {
                test: /\.m?js$/,
                exclude: /node_modules/,
                use: {
                    loader: "babel-loader",
                    options: {
                        presets: [["@babel/preset-env", {targets:{"ie": "11"}}]],
                        plugins: [
                            "@babel/plugin-proposal-class-properties",
                            "@babel/plugin-transform-arrow-functions"
                        ]
                    }
                }
            }
        ]
  }
};
我的
.babelrc

{
    "presets": [
        [
            "@babel/preset-env",
            {
                "targets": {
                    "ie": "11"
                },
                "useBuiltIns": "entry"
            }
        ]
    ],
    "plugins": [
        "@babel/plugin-proposal-class-properties",
        "@babel/transform-arrow-functions",
    ],
    "env": {
        "development": {},
        "test": {},
        "production": {}
    }
}
考虑到它是为IE11构建的,它不可能输出箭头函数——为什么?我如何设置配置,使其不输出箭头功能(使其在IE 11中工作)

{
    "presets": [
        [
            "@babel/preset-env",
            {
                "targets": {
                    "ie": "11"
                },
                "useBuiltIns": "entry"
            }
        ]
    ],
    "plugins": [
        "@babel/plugin-proposal-class-properties",
        "@babel/transform-arrow-functions",
    ],
    "env": {
        "development": {},
        "test": {},
        "production": {}
    }
}