Skip to content

Commit 00468eb

Browse files
maxime1992thymikee
authored andcommitted
docs: do not use .babelrc file but rather babel.config.js (#231)
Related to #64
1 parent 864440e commit 00468eb

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,25 @@ This tells `ts-jest` (a preprocessor this preset using to transform TS files) to
367367

368368
#### Transpile js files through `babel-jest`
369369
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.
370-
1. Install `babel-preset-env` and add `.babelrc` (or modify existing if needed) with that contents:
371-
```
372-
{
373-
"presets": ["env"]
374-
}
370+
371+
1. Install `@babel/preset-env` and add `babel.config.js` (or modify existing if needed) with the following content:
372+
```js
373+
module.exports = function(api) {
374+
api.cache(true);
375+
376+
const presets = ['@babel/preset-env'];
377+
const plugins = [];
378+
379+
return {
380+
presets,
381+
plugins,
382+
};
383+
};
384+
375385
```
386+
387+
*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!`*.
388+
376389
2. Update Jest configuration (by default TypeScript process untranspiled JS files which is source of the problem):
377390
```js
378391
{

0 commit comments

Comments
 (0)