babel

作者: 事在人为s | 来源:发表于2020-04-13 23:26 被阅读0次

环境搭建基本配置

package.json

{
  "name": "09-babel-demo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@babel/cli": "^7.7.5",
    "@babel/core": "^7.7.5",
    "@babel/plugin-transform-runtime": "^7.7.5",
    "@babel/preset-env": "^7.7.5"
  },
  "dependencies": {
    "@babel/polyfill": "^7.7.0",
    "@babel/runtime": "^7.7.5"
  }
}

.babelrc

{
    "presets": [
        [
            "@babel/preset-env",
            {
                "useBuiltIns": "usage",
                "corejs": 3
            }
        ]
    ],
    "plugins": [
        [
            "@babel/plugin-transform-runtime",
            {
                "absoluteRuntime": false,
                "corejs": 3,
                "helpers": true,
                "regenerator": true,
                "useESModules": false
            }
        ]
    ]
}

babal-polyfill

babal-polyfill => core-js + regenerator
babal7.4之后弃用babel-polyfill,直接使用core-js + regenerator
js新语法打补丁,使低版本浏览器支持新语法

babel-runtime

不污染全集环境,名字前加"_" _promise

相关文章

网友评论

      本文标题:babel

      本文链接:https://www.haomeiwen.com/subject/kpfamhtx.html