CRA will not read your .babelrc
.
Without ejecting the usual way is to use this two packages:
npm install --save-dev react-app-rewired customize-cra
Alter the scripts-section in package.json:
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test --env=jsdom",
"eject": "react-scripts eject"
},
Then you can install your preferred babel plugin:
npm install --save-dev @babel/plugin-proposal-nullish-coalescing-operator
Then create a config-overrides.js
file in the root directory.
const {override, addBabelPlugin} = require('customize-cra')
module.exports = override(
addBabelPlugin("@babel/plugin-proposal-nullish-coalescing-operator")
);
The 'internal' babel from CRA will be extended.
Consult the docs on github from the installed packages for further investigation:
react-app-rewired
customize-cra especially the api-docs (e.g. passing an array of plugins, caveats regarding the use of plugins in test-scripts ...)
I have tested this with a fresh created App with CRA and it works like a charm. As i used Javascript it should work with Typescript in a similar manner.