docs: update babel setup

closes #783
This commit is contained in:
dead_horse 2016-07-24 01:48:20 +08:00
parent 23903e7ef4
commit a1cdbdafcf
4 changed files with 10 additions and 12 deletions

View file

@ -119,22 +119,21 @@ app.use(convert(function *(next) {
```
## Babel setup
For Node 4.0 and Babel 6.0 you can setup like this
For Node 4.0 and Babel 6.0 you can setup like this:
```bash
// install babel and required presets
$ npm install babel-core --save
$ npm install babel-preset-es2015-node5 --save
$ npm install babel-preset-stage-3 --save
$ npm install babel-register transform-async-to-generator --save
```
```js
// set babel in entry file
require('babel-core/register')({
presets: ['es2015-node5', 'stage-3']
require('babel-register')({
plugins: ['transform-async-to-generator']
});
```
Check out an example in koa's [test](test/babel/index.js).
## Running tests

View file

@ -47,9 +47,9 @@
"tag": "next"
},
"devDependencies": {
"babel-core": "^6.1.2",
"babel-eslint": "^6.0.0",
"babel-plugin-transform-async-to-generator": "^6.0.14",
"babel-register": "^6.9.0",
"eslint": "^2.5.3",
"eslint-config-standard": "^5.1.0",
"eslint-plugin-babel": "^3.1.0",

View file

@ -1,3 +0,0 @@
{
"plugins": ["transform-async-to-generator"]
}

View file

@ -2,5 +2,7 @@
// http://babeljs.io/docs/setup/#babel_register
require('babel-core/register');
require('babel-register')({
plugins: ['transform-async-to-generator']
});
require('./_test.js');