Problem with babel config
See original GitHub issuethis is my babel.config.js
module.exports = {
presets: [
'@babel/preset-react',
'@babel/preset-flow',
[
'@babel/preset-env',
{
modules: false,
},
],
],
plugins: [
'react-hot-loader/babel',
'loadable-components/babel',
'babel-plugin-styled-components',
[
'relay',
{
schema: 'data/schema.json',
},
],
'material-ui',
'lodash',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-proposal-export-namespace-from',
],
overrides: [
{
test: ['./src/**/*.ts'],
presets: [
'@babel/preset-typescript',
[
'@babel/preset-env',
{
modules: false,
},
],
'@babel/preset-react',
],
},
],
env: {
test: {
presets: ['@babel/preset-flow', '@babel/preset-env', '@babel/preset-react'],
plugins: [
'@babel/plugin-transform-runtime',
'dynamic-import-node',
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-proposal-export-namespace-from',
],
},
},
};
it throws the following error
Error: Configuration contains string/RegExp pattern, but no filename was passed to Babel
because of overrides syntax that needs to accept a filename
I’ve solved this passing filename
to babel transform:
const code = babel.transformSync(preprocess(cmd), {
presets: [...]
plugins: [...]
filename: './babel.config.js', // hacky to make overrides works
}).code;
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
npx babel not reading configuration from babel.config.js
When running npx babel index.js from the command line, I was hoping I would see my babel configurations being applied from babel.config.js.
Read more >Configure Babel
Create a file called babel.config.json with the following content at the root of your project (where the package.json is). ... Check out the...
Read more >Solving Babel issue in Ejected React Application
It throws an Unexpected token syntax error. The issue is that Babel is no longer able to understand JSX (HTML like) syntax inside...
Read more >Babel
Storybook's webpack config by default sets up Babel for ES6 transpiling. ... part of @storybook/addon-essentials , as this currently causes issues in IE11....
Read more >ESLint: Parsing error: No Babel config file detected ... - YouTrack
ESLint: Parsing error: No Babel config file detected (using @babel/eslint-parser) ... Hello,. Since moving from the deprecated babel-eslint to the recommended @ ...
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 FreeTop 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
Top GitHub Comments
I narrowed this down to having a pattern in something like an
ignore
field for example a config file like thisbabel.config.js
caused the error:For me I realised I didn’t need this particular ignore. I couldn’t find the magic combination of options for
babel.transform
to get it to work. Hope that gets this issue a step closer.Running into this also now. Is babel/ts transpilation really necessary? This definitely feels like something that shouldn’t exist.