addBabelPlugins is not working
See original GitHub issueIn CRA3, I get an error of typescript namespace which is
Non-declarative namespaces are only supported experimentally in Babel.
look like I need @babel/plugin-transform-typescript
to resolve it, but I add it uses addBabelPlugins
still get this error.
module.exports = config => {
const {
entry,
resolve = {},
module: {rules},
} = config;
const {alias = {}} = resolve;
// find index of eslint rule
const findRuleIndex = cb => rules.findIndex(rule => cb(rule));
const eslintRuleIndex = findRuleIndex(
({use}) => use && /eslint/.test(use[0].loader),
);
config.module.rules.splice(eslintRuleIndex, 1);
config.entry.pop();
config.entry = [...entry, Path.resolve('./src/app/index.tsx')];
return override(
addWebpackAlias({
...alias,
'~': Path.resolve('src/app'),
'~imgs': Path.resolve('src/app/assets/static'),
}),
...addBabelPlugins([
'@babel/plugin-transform-typescript',
{allowNamespaces: true},
]),
)(config);
};
This is my override config file.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
React-App- Rewired won't add Babel Plugin - Stack Overflow
I am using a config-overrides.js file that looks like this: const { override, addBabelPlugins, addDecoratorsLegacy, fixBabelImports } = require( ...
Read more >How to use the customize-cra.addBabelPlugin function ... - Snyk
Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues...
Read more >Customize-cra-my NPM - npm.io
A simple helper that calls addBabelPlugin for each plugin you pass in here. Make sure you use the spread operator when using this,...
Read more >@zhigang1992/customize-cra - npm
addBabelPlugins (plugins). A simple helper that calls addBabelPlugin for each plugin you pass in here. Make sure you use the spread operator when ......
Read more >Modify Create React App's Babel Configuration Without Ejecting
We're not calling react-app-rewired directly, but it's a required ... In our case, addBabelPlugins is what we need to add both plugins.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@m93a now it work!
This is weird… I use a minimal config with:
but Babel acts as if the option
allowNamespaces
wasn’t there…@youncccat Did you figure it out?