如何从Babel编译代码中删除符号类型的转换类型?

我最近将babel添加到了gulpfile中,以便可以开始在ES6中编写代码。该代码正在按预期进行编译,但是我注意到以下代码行已在多个位置添加到已编译的JS文件中。我认为我不需要它,因此想删除它:

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

我尝试过的事情

gulpfile.babel.js的{​​{1}}内部,我像这样设置createBuildTask()presets

...导致在gulp构建期间返回以下错误:

'presets': [['env',{'exclude': ['transform-typeof-symbol']}]]

这是删除的正确方法,还是应该以其他方式处理?下面,我包括了Invalid Option: The plugins/built-ins 'transform-typeof-symbol' passed to the 'exclude' option are not valid. Please check data/[plugin-features|built-in-features].js in babel-preset-envpackage.json的相关部分。

package.json (包括 dev devDependencies

gulpfile.babel.js

gulpfile.babel.js

"devDependencies": {
    "babel-core": "^6.26.3","babel-eslint": "^7.2.3","babel-preset-env": "^1.7.0","babel-register": "^6.26.0","del": "^2.2.2","eslint": "^6.6.0","gulp": "^4.0.2","gulp-babel": "^7.0.1","gulp-concat": "^2.6.1","gulp-eslint": "^6.0.0","gulp-rename": "^1.2.2","gulp-terser": "^1.2.0"
},"dependencies": {
    "babel-plugin-transform-remove-strict-mode": "0.0.2","babel-polyfill": "^6.26.0","lodash": "^4.17.15"
}
nmwangyu 回答:如何从Babel编译代码中删除符号类型的转换类型?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3157476.html

大家都在问