Skip to content
This repository has been archived by the owner on May 11, 2018. It is now read-only.

Commit

Permalink
docs [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
hzoo committed Nov 2, 2016
1 parent e42bc1a commit 734619d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Currently: "chrome, edge, firefox, safari, ie, node".

> Note, browsers' results are overridden by explicit items from `targets`.
> If your config is a js file, also do `"node": parseFloat(process.versions.node)`
If you want to compile against the current node version, you can specify `"node": true` or `"node": "--version"` which would be the same as `node": parseFloat(process.versions.node)`

* `loose` (boolean) - Enable "loose" transformations for any plugins in this preset that allow them (Defaults to `false`).
* `modules` - Enable transformation of ES6 module syntax to another module type (Defaults to `"commonjs"`).
Expand All @@ -64,7 +64,7 @@ Currently: "chrome, edge, firefox, safari, ie, node".
* `whitelist` (Array<string>) - Enable a whitelist of plugins to always include. (Defaults to `[]`)
* Useful if there is a bug in a native implementation, or a combination of a non-supported feature + a supported one doesn't work. (Ex: Node 4 supports native classes but not spread)

### Example
### Examples

```js
// src
Expand Down Expand Up @@ -141,6 +141,26 @@ export var A = function A() {
};
```

#### Example with `node: true` or `node: "--version"`

```js
// process.versions.node -> 6.9.0
{
"presets": [
["env", {
"targets": {
"node": "--version"
}
}]
]
}

// ...

class A {}
exports.A = A;
```

### Example with `debug: true`

```js
Expand Down Expand Up @@ -179,7 +199,6 @@ syntax-trailing-function-commas {}
transform-es2015-arrow-functions {}
```


## Caveats

### Using `babel-plugin-transform-object-rest-spread` and targeting node.js 6.5 or higher
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const getCurrentNodeVersion = () => {
};

export const getTargets = (targetOpts = {}) => {
if (targetOpts.node === "--version") {
if (targetOpts.node === true || targetOpts.node === "--version") {
targetOpts.node = getCurrentNodeVersion();
}

Expand Down

0 comments on commit 734619d

Please sign in to comment.