While utilizing Babel 7 and Gulp 4 in conjunction, I have noticed that the subsequent line of code is repeated five times within my build:
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); }
Could there be something amiss as this seems redundant? Below are specifics of my setup:
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 (contains only the function utilized for the build task)
function createBuildTask() {
var sourceArray = [
// The actual building process involves 12 different files but has been condensed here
'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'));
};
}
Steps taken so far:
Applying options to @babel/preset-env:
'presets': [['@babel/preset-env', { 'modules': false, 'useBuiltIns': 'entry', 'corejs': 3 }]], 'plugins': ['@babel/plugin-transform-runtime']
...yet the duplicated lines revolving around Symbol persist even after compilation.
What would be the correct approach to eliminate this duplication and ensure that the aforementioned line of code appears just once?