From 00468eb93f78583106ba3a4451d489e95c1bd288 Mon Sep 17 00:00:00 2001 From: Maxime Date: Fri, 1 Mar 2019 12:17:05 +0000 Subject: [PATCH] docs: do not use .babelrc file but rather babel.config.js (#231) Related to thymikee/jest-preset-angular#64 --- README.md | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8880a022a3..8f6dcb62ff 100644 --- a/README.md +++ b/README.md @@ -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 {