`@babel/core` `parseSync` does not handle `exclude` in config
See original GitHub issueBug Report
- I would like to work on a fix!
Current Behavior
- REPL, Codesandbox, or GitHub Repo link if applicable: https://github.com/SimenB/babel-parse-exclude
Input Code
Expected behavior/code
Passing an empty string to parseSync
will throw if config file contains exclude
.
Error: Configuration contains string/RegExp pattern, but no filename was passed to Babel
This is sorta documented (https://babeljs.io/docs/en/options#filename) but I find it very confusing 😀 There aren’t really any parse info inferred from filename (I think?), at least not when we pass parserOpts
.
Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
- Filename:
babel.config.js
module.exports = {exclude: /react-native/};
Environment
System:
OS: macOS Mojave 10.14.6
Binaries:
Node: 12.16.3 - ~/.nvm/versions/node/v12.16.3/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.4 - ~/.nvm/versions/node/v12.16.3/bin/npm
npmPackages:
@babel/core: ^7.9.6 => 7.9.6
- Babel version(s): 7.9.6
- Node/npm version: v12
- OS: osx
- Monorepo: no
- How you are using Babel:
@babel/core
’sparseSync
Possible Solution
I would expect this error to be suppressed when we use parse
API, same as when we use @babel/parser
directly.
Additional context/Screenshots
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Options - Babel.js
Defaults to searching for a default babel.config.json file, but can be passed the path of any JS or JSON5 config file. NOTE: This...
Read more >codesandbox eslint config | The AI Search Engine You Control
Expected behavior/code Passing an empty string to parseSync will throw if config file contains exclude . Error: Configuration contains string/RegExp pattern, ...
Read more >Webpack, babel - node_modules are not excluded from bundle
I tried different configuration of .babel-rc, terser and awesome-typescript-loader (exclude /node_modules/) but node_modules are still inside ...
Read more >babel-loader - webpack
npm install -D babel-loader @babel/core @babel/preset-env webpack ... To exclude node_modules , see the exclude option in the loaders config as documented ...
Read more >How to Webpack 5 with Babel - Setup Tutorial
By using Babel, the code which isn't supported yet, will get transpiled ... which folders to exclude from the process (e.g. node_modules):.
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
@nicolo-ribaudo It’s not that the stack frames are missed, it’s just that there are so many they overload the default
Error.stackTraceLimit
of 10. Here is the complete stack trace @SimenB shared with me, produced whenError.stackTraceLimit = 100;
was set:Everything above
loadFullConfig
from@babel/core/lib/config/full.js
is not really helpful to users of babel IMO. One way would be to have a try/catch inloadFullConfig
rewrite the stack-trace of config validation errors:exclude
/include
can be functions so that can receive anundefined
filename.