babel-preset-node5
Advanced tools
Comparing version 11.1.0 to 12.0.0
47
index.js
/* global module */ | ||
module.exports = { | ||
plugins: [ | ||
require('babel-plugin-syntax-async-functions'), | ||
require('babel-plugin-syntax-object-rest-spread'), | ||
require('babel-plugin-syntax-trailing-function-commas'), | ||
require('babel-plugin-transform-es2015-destructuring'), | ||
require('babel-plugin-transform-es2015-modules-commonjs'), | ||
require('babel-plugin-transform-es2015-parameters'), | ||
require('babel-plugin-transform-es2015-sticky-regex'), | ||
require('babel-plugin-transform-es2015-unicode-regex'), | ||
require('babel-plugin-transform-strict-mode'), | ||
require('babel-plugin-transform-object-rest-spread'), | ||
require('babel-plugin-transform-async-to-generator'), | ||
], | ||
}; | ||
module.exports = function(context, opts = {}) { | ||
let loose = false; | ||
let modules = true; | ||
if (opts !== undefined) { | ||
if (opts.loose !== undefined) loose = opts.loose; | ||
if (opts.modules !== undefined) modules = opts.modules; | ||
} | ||
if (typeof loose !== 'boolean') throw new Error("Preset node5 'loose' option must be a boolean."); | ||
if (typeof loose !== 'boolean') throw new Error("Preset node5 'modules' option must be a boolean."); | ||
// be DRY | ||
const optsLoose = { loose }; | ||
return { | ||
plugins: [ | ||
require('babel-plugin-syntax-async-functions'), | ||
require('babel-plugin-syntax-object-rest-spread'), | ||
require('babel-plugin-syntax-trailing-function-commas'), | ||
[require('babel-plugin-transform-es2015-destructuring'), optsLoose], | ||
modules && [require('babel-plugin-transform-es2015-modules-commonjs'), optsLoose], | ||
require('babel-plugin-transform-es2015-parameters'), | ||
require('babel-plugin-transform-es2015-sticky-regex'), | ||
require('babel-plugin-transform-es2015-unicode-regex'), | ||
require('babel-plugin-transform-strict-mode'), | ||
require('babel-plugin-transform-object-rest-spread'), | ||
require('babel-plugin-transform-async-to-generator'), | ||
].filter(Boolean) // filter out falsy values | ||
}; | ||
} |
{ | ||
"name": "babel-preset-node5", | ||
"version": "11.1.0", | ||
"description": "Babel preset for Node 5.x (ES6 / ES2015)", | ||
"version": "12.0.0", | ||
"description": "Babel preset for Node 5.x (ECMAScript stage 0 and up)", | ||
"repository": "git://github.com/leebenson/babel-preset-node5.git", | ||
@@ -21,15 +21,15 @@ "main": "index.js", | ||
"dependencies": { | ||
"babel-plugin-syntax-async-functions": "^6.8.0", | ||
"babel-plugin-syntax-object-rest-spread": "^6.8.0", | ||
"babel-plugin-syntax-trailing-function-commas": "^6.8.0", | ||
"babel-plugin-transform-async-to-generator": "^6.8.0", | ||
"babel-plugin-transform-es2015-destructuring": "^6.8.0", | ||
"babel-plugin-transform-es2015-modules-commonjs": "^6.8.0", | ||
"babel-plugin-transform-es2015-parameters": "^6.8.0", | ||
"babel-plugin-syntax-async-functions": "^6.13.0", | ||
"babel-plugin-syntax-object-rest-spread": "^6.13.0", | ||
"babel-plugin-syntax-trailing-function-commas": "^6.13.0", | ||
"babel-plugin-transform-async-to-generator": "^6.16.0", | ||
"babel-plugin-transform-es2015-destructuring": "^6.19.0", | ||
"babel-plugin-transform-es2015-modules-commonjs": "^6.18.0", | ||
"babel-plugin-transform-es2015-parameters": "^6.18.0", | ||
"babel-plugin-transform-es2015-sticky-regex": "^6.8.0", | ||
"babel-plugin-transform-es2015-unicode-regex": "^6.8.0", | ||
"babel-plugin-transform-object-rest-spread": "^6.8.0", | ||
"babel-plugin-transform-strict-mode": "^6.8.0", | ||
"babel-polyfill": "^6.8.0" | ||
"babel-plugin-transform-es2015-unicode-regex": "^6.11.0", | ||
"babel-plugin-transform-object-rest-spread": "^6.19.0", | ||
"babel-plugin-transform-strict-mode": "^6.18.0", | ||
"babel-polyfill": "^6.16.0" | ||
} | ||
} |
# Babel 6.x presets for Node 5.x (updated regularly!) | ||
Node 5.x brings ~59% [native ES6/ES2015 coverage](https://nodejs.org/en/docs/es6/). This preset for Babel 6 attempts | ||
to bridge the gap for the much of the remaining 41% using [Babel plug-ins](https://github.com/babel/babel/tree/master/packages). | ||
Node 5.x brings ~59% [native ES6/ES2015 coverage](https://nodejs.org/en/docs/es6/). | ||
This preset for Babel 6 attempts to bridge the gap for the much of the remaining 41% of the evolving ECMAScript spec using [Babel plug-ins](https://github.com/babel/babel/tree/master/packages), from stage 0 and up. | ||
## Motivation | ||
@@ -127,8 +128,18 @@ | ||
## No longer tracking Babel 6 versions | ||
## Using with Webpack 2 or Rollup? | ||
This package originally tracked Babel 6.x versioning. The problem is, many of the plug-ins and transforms provided by Babel don't always track the the `babel-core` version, so updating one dependency can throw the versioning schema off. | ||
If you want to enable 'tree shaking' in Webpack 2 or Rollup, you can optionally remove transpiling down to CommonJS by passing `{ "modules": false }` as an option when including this module in your `.babelrc` file, like so: | ||
This package will instead now follow its own semver, starting (arbitrarily) at v10.0.0. | ||
```js | ||
{ | ||
"presets": [ | ||
["node5", { | ||
"modules": false | ||
}] | ||
] | ||
} | ||
``` | ||
I'm using this repo in production, so you can be assured that I'm making it a priority to update Babel 6 deps regularly and track the latest plug-in versions. | ||
## Using Node 7.x? | ||
Check out [babel-preset-node7](https://www.npmjs.com/package/babel-preset-node7) |
8971
5
28
145