In this lesson we'll show how to setup a .babelrc file with presets and plugins. Then create npm scripts that use babel-node and babel. With babel-preset-env we'll show how to target specific versions of node and how to use babel plugins, while not transpiling features (like async await) that are already supported by node natively.

package.json:

"devDependencies": {
"babel-cli": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-preset-env": "^1.5.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1"
},

.babelrc:

{
"presets": ["react", "es2015", ["env", {
"targets": {
"node": "current"
}
}]],
"plugins": ["transform-object-rest-spread"]
}

node: "current", compile code based on your node version.

Node version larger than 7.6 will have async/await support by defualt. So if we already have 7.6 above, we don't want Babel to compile async/await to ES5 code.

  "presets": ["react", "es2015", ["env", {
"targets": {
"node": 7.6
}
}]]

最新文章

  1. 贝塞尔曲线(UIBezierPath)属性、方法汇总
  2. Gradle 刷新依赖
  3. Web开发人员必读的12个网站
  4. Sql Server事务简单用法
  5. ssh An internal error occured during "Add Deployment"
  6. [转]使用onclick跳转到其他页面/跳转到指定url
  7. jenkins创建git任务连接时遇到的问题
  8. Hibernate 、继承关联映射
  9. Java Scanner 类
  10. PHP中cURL的应用
  11. 【Linux基础】大B和小b
  12. mysql export query result
  13. ORM框架学习之EF
  14. ifdown eth0或service network restart
  15. go-003-基础语法
  16. matlab实现MSER(最大极值稳定区域)来进行文本定位
  17. centos7 VNC安装
  18. python's metaclass
  19. 0821Servlet基础
  20. JeeSite基础知识(一)

热门文章

  1. WebService 获取客户端 IP 和 MAC 等信息
  2. BZOJ 1604 [Usaco2008 Open]Cow Neighborhoods 奶牛的邻居 Treap
  3. Irrlicht 3D Engine 笔记系列 之 教程5- User Interface
  4. mac下的词典翻译快捷键
  5. 互联网+时代IT管理者的转型
  6. Mysql数据库存储引擎--转
  7. ftp实现图片上传,文件也类似
  8. angularjs 合并单元格
  9. CF1009F Dominant Indices(树上DSU/长链剖分)
  10. 5.9 enum--支持枚举类型