babel-preset-node8
v1.2.0
Published
Babel preset for Node 7.10-8
Downloads
3,996
Maintainers
Readme
babel-preset-node8
Babel 6+ presets for Node 7.10-8.x
Node v7.10 comes with native support of async/await. This preset for Babel 6 adds some remaining features. Also plugin has plugins to build production-ready "fast" code.
Included plugins
- transform-es2015-modules-commonjs
- transform-class-properties
- transform-object-rest-spread
- transform-export-extensions
- transform-async-generator-functions
- syntax-trailing-function-commas
Plugins in env.production
- transform-es2015-block-scoping
- transform-es2015-for-of with
{ "loose": true }
- transform-inline-consecutive-adds
- minify-dead-code-elimination
Installation
npm install --save-dev babel-preset-node8
Usage
Via .babelrc
(recommended)
Create a .babelrc
file in your project root, and include node8
in your presets list.
{
"presets": ["node8"]
}
Now whenever you can use latest ECMAScript features with babel-node
or babel-cli
.
Via CLI
babel source.js --presets node8
# or
babel ./src -d ./dist --presets node8
Via Node API
require('babel-core').transform('Your source code', {
presets: ['node8'],
})
Also you can use babel-register
to transpile in runtime:
require('babel-register')
require('./path/to/es6-7/sources')
Webpack, Rollup, Browserify, Gulp, etc.
Follow vendor instructions and include node8
preset in your babel "preset" list (if needed).
React support
Babel already has a preset for React, and you now need to install it separately.
npm install --save-dev babel-preset-react
And then add it to your "presets" list in .babelrc
file:
{
"presets": [
"node8",
"react"
]
}
Credits
Created by Sergey Sova (LestaD).