babel升级7.xx总结
栏目: JavaScript · 发布时间: 5年前
npx babel-upgrade --write --install
二、手动升级
2.1 安装依赖
// Babel-loader 8.x "babel-loader" // Babel-core 7.x "@babel/core" // Env "@babel/preset-env" // Runtime "@babel/runtime" "@babel/plugin-transform-runtime" // React "@babel/preset-react" // Stage 0 "@babel/plugin-proposal-function-bind" // Stage 1 "@babel/plugin-proposal-export-default-from" "@babel/plugin-proposal-logical-assignment-operators" "@babel/plugin-proposal-optional-chaining" "@babel/plugin-proposal-pipeline-operator" "@babel/plugin-proposal-nullish-coalescing-operator" "@babel/plugin-proposal-do-expressions" // Stage 2 "@babel/plugin-proposal-decorators" "@babel/plugin-proposal-function-sent" "@babel/plugin-proposal-export-namespace-from" "@babel/plugin-proposal-numeric-separator" "@babel/plugin-proposal-throw-expressions" // Stage 3 "@babel/plugin-syntax-dynamic-import" "@babel/plugin-syntax-import-meta" "@babel/plugin-proposal-class-properties" "@babel/plugin-proposal-json-strings"
2.2 修改.babelrc
{ "presets": [ ["@babel/preset-env", { "targets": { "browsers": [ "last 2 versions", "Firefox ESR", "> 1%", "ie >= 9", "iOS >= 8", "Android >= 4" ] } }], "@babel/preset-react" ], "plugins": [ "@babel/plugin-transform-runtime", "@babel/plugin-proposal-function-bind", "@babel/plugin-proposal-export-default-from", "@babel/plugin-proposal-logical-assignment-operators", ["@babel/plugin-proposal-optional-chaining", { "loose": false }], ["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal" }], ["@babel/plugin-proposal-nullish-coalescing-operator", { "loose": false }], "@babel/plugin-proposal-do-expressions", ["@babel/plugin-proposal-decorators", { "legacy": true }], "@babel/plugin-proposal-function-sent", "@babel/plugin-proposal-export-namespace-from", "@babel/plugin-proposal-numeric-separator", "@babel/plugin-proposal-throw-expressions", "@babel/plugin-syntax-dynamic-import", "@babel/plugin-syntax-import-meta", ["@babel/plugin-proposal-class-properties", { "loose": true }], "@babel/plugin-proposal-json-strings" ], "comments": false, "compact": false }
以上所述就是小编给大家介绍的《babel升级7.xx总结》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- React 16 升级总结
- 升级Debian版本操作总结
- SpringCloud微服务架构升级总结
- Android targetSdkVersion 升级到 26 总结
- cnpm 核心模块 npminstall 升级到 async 总结
- Android Studio升级3.2以后 Androidx 异常总结
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。