babel

1、babel
deprecated(不安装也能跑)
日期:2017-02-13 23:04:30,版本:6.23.0

1
npm i -D babel

2、babel-core

  • Babel compiler core.(转换核心包)
  • babel-loader 依赖于它

日期:2017-08-16 15:54:21,版本:6.26.0
日期:2017-03-13 02:18:11,版本:6.24.0

1
npm i -D babel-core

3、babel-loader

  • 在 webpack 中使用 Babel
  • This package allows transpiling JavaScript files using Babel and webpack.

日期:2018-03-06 09:51:32,版本:7.1.4
日期:2017-03-16 09:07:01,版本:6.4.1

1
npm i -D babel-loader

4、babel-preset-es2015

  • 转换 ES6 语法,如箭头函数、class语法、解析赋值、字符串模版等
  • deprecate babel-preset-es2015@^6.24.0 ???? Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!

日期:2017-03-13 02:18:17,版本:6.24.0

1
npm i -D babel-preset-es2015

1
2
3
{
"presets": ["es2015"]
}

Babel核心用法记要

5、babel-polyfill
转换 babel-preset-es2015 无法转换的 Promise、generator 等函数

1
npm i -D babel-runtime

三种引用方式

1
2
3
4
5
require('babel-polyfill')
import 'babel-polyfill'
module.exports = {
entry: ['babel-polyfill', './src/main.js']
}

babel-polyfill的引用和使用

参考:
官网
再见,babel-preset-2015

6、babel-runtime

  • babel-plugin-transform-runtime 依赖于它
  • babel-runtime 插件的作用,简单来说,就是优化babel-preset-es2015,babel-polyfill的使用:
    (1)提取了 转换ES6 语法时的公共代码,减少了转换后的重复代码
    (2)可使编译完成的代码的全局对象不被babel-polyfill 污染

日期:2017-08-16 15:54:10,版本:6.26.0
日期:2017-02-14 19:27:09,版本:6.23.0

1
npm i -S babel-runtime

7、babel-plugin-transform-runtime

  • Externalise references to helpers and builtins, automatically polyfilling your code without polluting globals. (This plugin is recommended in a library/tool)
  • 依赖于 babel-runtime

日期:2017-02-13 23:04:28,版本:6.23.0

1
npm i -D babel-plugin-transform-runtime

1
2
3
{
"plugins": ["transform-runtime"]
}

参考

  1. babel-plugin-transform-runtime 和 babel-runtime 的区别?

  2. babel-preset-es2015,babel-polyfill 与 babel-plugin-transform-runtime

  3. babel-runtime 和 babel-polyfill