Skip to content

@babel/core parseSync does not handle exclude in config #11540

@SimenB

Description

@SimenB

Bug Report

  • I would like to work on a fix!

Current Behavior

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's parseSync

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: errorsoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions