Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: do not use .babelrc file but rather babel.config.js #231

Merged
merged 1 commit into from
Mar 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,25 @@ This tells `ts-jest` (a preprocessor this preset using to transform TS files) to

#### Transpile js files through `babel-jest`
Some vendors publish their sources without transpiling. You need to say jest to transpile such files manually since `typescript` (and thus `ts-jest` used by this preset) do not transpile them.
1. Install `babel-preset-env` and add `.babelrc` (or modify existing if needed) with that contents:
```
{
"presets": ["env"]
}

1. Install `@babel/preset-env` and add `babel.config.js` (or modify existing if needed) with the following content:
```js
module.exports = function(api) {
api.cache(true);

const presets = ['@babel/preset-env'];
const plugins = [];

return {
presets,
plugins,
};
};

```

*Note: do not use a `.babelrc` file otherwise the packages that you specify in the next step will not be picked up. CF [Babel documentation](https://babeljs.io/docs/en/configuration#what-s-your-use-case) and the comment `You want to compile node_modules? babel.config.js is for you!`*.

2. Update Jest configuration (by default TypeScript process untranspiled JS files which is source of the problem):
```js
{
Expand Down