docs: update readme to add babel 7 instructions (#1274)

This commit is contained in:
Vikram Rangaraj 2018-12-06 23:23:18 -08:00 committed by Yiyu He
parent 5560f72912
commit fc93c05f68

View file

@ -161,16 +161,22 @@ Learn more about the application object in the [Application API Reference](docs/
## Babel setup
If you're not using `node v7.6+`, we recommend setting up `babel` with [`babel-preset-env`](https://github.com/babel/babel-preset-env):
If you're not using `node v7.6+`, we recommend setting up `babel` with [`@babel/preset-env`](https://babeljs.io/docs/en/next/babel-preset-env):
```bash
$ npm install babel-register babel-preset-env --save
$ npm install @babel/register @babel/preset-env @babel/cli --save-dev
```
Setup `babel-register` in your entry file:
In development, you'll want to use [`@babel/register`](https://babeljs.io/docs/en/next/babel-register):
```js
require('babel-register');
```bash
node --require @babel/register <your-entry-file>
```
In production, you'll want to build your files with [`@babel/cli`](https://babeljs.io/docs/en/babel-cli). Suppose you are compiling a folder `src` and you wanted the output to go to a new folder `dist` with non-javascript files copied:
```bash
babel src --out-dir dist --copy-files
```
And have your `.babelrc` setup:
@ -178,7 +184,7 @@ And have your `.babelrc` setup:
```json
{
"presets": [
["env", {
["@babel/preset-env", {
"targets": {
"node": true
}