babel-preset-node8

2019-07-14 admin

babel-preset-node8是什么

什么是babel-preset-node8,Babel preset for Node 7.10-8

babel-preset-node8使用教程帮助文档

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

Plugins in env.production

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).

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-69741.html

文章标题:babel-preset-node8

回到顶部