1 babel 语法转换原理
js code=>ast语法树=》(转换)ast语法树=>js code
转换ast语法树的时候,只能转换语法,并不能解决,缺少Promise对象等问题,所以就带来了pollyfill
2 pollyfill
babel-polyfill,它的初衷是**模拟(emulate)**一整套 ES2015+ 运行时环境,
所以它的确会以全局变量的形式 polyfill Map、Set、Promise 之类的类型
3 所以看package.json
babel-polyfill是包含在dependencies里面,需要打包生成模拟es6的运行时环境
babel是在devDependencied里面,只需要在开发时执行语法转换即可
"dependencies": {
"@antv/g6": "^3.5.6",
"axios": "^0.19.2",
"babel-polyfill": "^6.26.0",
},
"devDependencies": {
"@vue/cli-plugin-babel": "^4.2.0",
"@vue/cli-plugin-eslint": "^4.2.0",
"@vue/cli-plugin-router": "^4.2.0",
"@vue/cli-plugin-vuex": "^4.2.0",
"@vue/cli-service": "^4.2.0",
"autoprefixer": "^9.8.4",
"babel-eslint": "^10.0.3"
}