Javascript 为什么巴贝尔要在我的构建中添加这行重复的代码?

Javascript 为什么巴贝尔要在我的构建中添加这行重复的代码?,javascript,npm,ecmascript-6,gulp,babeljs,Javascript,Npm,Ecmascript 6,Gulp,Babeljs,我同时使用Babel 7和Gulp 4,发现以下代码行在我的构建中出现了5次: function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = f

我同时使用Babel 7和Gulp 4,发现以下代码行在我的构建中出现了5次:

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
也许我遗漏了什么,但这似乎是多余的?我的配置的详细信息可以在下面找到:

package.json

"devDependencies": {
    "@babel/core": "^7.8.4",
    "@babel/plugin-transform-runtime": "^7.8.3",
    "@babel/preset-env": "^7.8.4",
    "@babel/register": "^7.8.3",
    "babel-eslint": "^10.0.3",
    "del": "^5.1.0",
    "eslint": "^6.8.0",
    "gulp": "^4.0.2",
    "gulp-babel": "^8.0.0",
    "gulp-concat": "^2.6.1",
    "gulp-eslint": "^6.0.0",
    "gulp-rename": "^2.0.0",
    "gulp-terser": "^1.2.0"
},
"dependencies": {
    "@babel/runtime": "^7.8.4",
    "core-js": "^3.6.4",
    "lodash": "^4.17.15"
}
gulpfile.babel.js(仅包括用于构建任务的函数)

我所尝试的

  • 将选项传递到@babel/预设环境:

    “预设”:[['@babel/preset env'{
    “模块”:false,
    'useBuiltIns':'entry',
    “corejs”:3
    }]],
    “插件”:[“@babel/plugin transform runtime”]

  • …但符号的重复代码行在编译后仍然存在

    正确的方法是什么,使前面提到的代码行只出现一次

    function createBuildTask() {
        var sourceArray = [
            // I'm building from 12 different files, but have simplified for this posting
            'file1.js', 'file2.js', 'file3.js', 'file4.js', ...
        ];
    
        return function () {
            return gulp.src(sourceArray, {'allowEmpty': true})
                .pipe(babel({
                    'presets': ['@babel/preset-env'],
                    'plugins': []
                }))
                .pipe(concat('desktop-built.js'))
                .pipe(gulp.dest('desktop/dist'))
                .pipe(terser())
                .pipe(rename({
                    'extname': '.min.js'
                }))
                .pipe(gulp.dest('desktop/dist'));
        };
    }