1 | # babel-preset-latest-node [![NPM version][npm-image]][npm-url]
|
2 |
|
3 | babel preset latest for node 7 (latest) or node 6 (LTS)
|
4 |
|
5 | [![Dependency ci Status][dependencyci-image]][dependencyci-url]
|
6 | [![Dependency Status][daviddm-image]][daviddm-url]
|
7 |
|
8 | ## Alternatives
|
9 |
|
10 | - [babel-preset-env](https://www.npmjs.com/package/babel-preset-env)
|
11 |
|
12 | ## Options
|
13 |
|
14 | - `target`: `6`, `7` or `'current'`
|
15 | - `loose`: Enable “loose” transformations for any plugins in this preset that allow them (Disabled by default).
|
16 | - `modules` - Enable transformation of ES6 module syntax to another module type (Enabled by default to "commonjs"). Can be false to not transform modules, or "commonjs"
|
17 | - `es2016` - Enable es2016 features (Enabled by default)
|
18 | - `es2017` - Enable es2017 features (Enabled by default)
|
19 |
|
20 | ## [Compatibility Table](http://node.green/)
|
21 |
|
22 |
|
23 | | Feature | Node 6 | Node 6.5 | Node 7 | Node 7.6 |
|
24 | | ------- | ------ | -------- | ------ | -------- |
|
25 | | <h3>ES2015</h3> |||||
|
26 | | [transform-es2015-modules-commonjs](https://babeljs.io/docs/plugins/transform-es2015-modules-commonjs) | no | no | no | no |
|
27 | | [transform-es2015-function-name](https://babeljs.io/docs/plugins/transform-es2015-function-name) | no | yes | yes | yes |
|
28 | | <h3>ES2016</h3> |||||
|
29 | | [transform-exponentiation-operator](https://babeljs.io/docs/plugins/transform-exponentiation-operator) | no | flag | yes | yes |
|
30 | | <h3>ES2017</h3> |||||
|
31 | | [syntax-trailing-function-commas](https://babeljs.io/docs/plugins/syntax-trailing-function-commas) | no | no | no | no |
|
32 | | [transform-async-to-generator](https://babeljs.io/docs/plugins/transform-async-to-generator) | no | no | flag | yes |
|
33 |
|
34 | ## Install
|
35 |
|
36 | ```bash
|
37 | npm install --save-dev babel-preset-latest-node
|
38 | yarn add --dev babel-preset-latest-node
|
39 | ```
|
40 |
|
41 | ## Usage
|
42 |
|
43 | ### Via `.babelrc`
|
44 |
|
45 | **.babelrc**
|
46 |
|
47 | ```json
|
48 | {
|
49 | "presets": ["latest-node"]
|
50 | }
|
51 | ```
|
52 |
|
53 | ```json
|
54 | {
|
55 | "presets": [["latest-node", { "target": "current" }]]
|
56 | }
|
57 | ```
|
58 |
|
59 | ### Via CLI
|
60 |
|
61 | ```sh
|
62 | babel script.js --presets latest-node
|
63 | ```
|
64 |
|
65 | ### Via Node API
|
66 |
|
67 | ```javascript
|
68 | require("babel-core").transform("code", {
|
69 | presets: [require('babel-preset-latest-node')]
|
70 | });
|
71 | ```
|
72 |
|
73 | ```javascript
|
74 | require("babel-core").transform("code", {
|
75 | presets: [[require('babel-preset-latest-node'), { target: 'current' }]]
|
76 | });
|
77 | ```
|
78 |
|
79 | [npm-image]: https://img.shields.io/npm/v/babel-preset-latest-node.svg?style=flat-square
|
80 | [npm-url]: https://npmjs.org/package/babel-preset-latest-node
|
81 | [daviddm-image]: https://david-dm.org/christophehurpeau/babel-preset-latest-node.svg?style=flat-square
|
82 | [daviddm-url]: https://david-dm.org/christophehurpeau/babel-preset-latest-node
|
83 | [dependencyci-image]: https://dependencyci.com/github/christophehurpeau/babel-preset-latest-node/badge?style=flat-square
|
84 | [dependencyci-url]: https://dependencyci.com/github/christophehurpeau/babel-preset-latest-node
|