Skip to content

Commit

Permalink
docs: setting up babel, use package.json instead
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanVann committed Jan 25, 2019
1 parent 6b00aee commit ff324e5
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,22 @@ Install `@babel/polyfill`:
yarn add @babel/polyfill
```

Load the polyfill in your Jest configuration:
Load the polyfill and configure Babel in your `package.json` file:

```json
// package.json
{
"jest": {
"setupFiles": ["@babel/polyfill"]
},
"babel": {
"presets": ["@babel/preset-env", "@babel/preset-react"]
}
}
```

You should also import `@babel/polyfill` in your app. If you are creating a library you should look into using [`@babel/plugin-transform-runtime`](https://babeljs.io/docs/en/babel-plugin-transform-runtime) instead.

Create a [`babel.config.js`](https://babeljs.io/docs/en/config-files) file in your project's root folder:

```js
module.exports = {
presets: ['@babel/preset-env', '@babel/preset-react'],
};
```

You are now set up to use all ES2018 features and [React](https://reactjs.org) specific syntax. If you are not using React you can exclude `@babel/preset-react` from the above commands/config.

> Note: `babel-jest` is automatically installed when installing Jest and will automatically transform files if a babel configuration exists in your project. To avoid this behavior, you can explicitly reset the `transform` configuration option:
Expand Down

0 comments on commit ff324e5

Please sign in to comment.