Skip to content

Loading .cjs config files on Node 13 #10595

Closed

Description

@the-spyke

Feature Request

Is your feature request related to a problem? Please describe.

If you have Node 13 and babel.config.js file in a package with type=module then Node will emit a warning:

(node:22720) Warning: require() of ES modules is not supported.
require() of /home/spyke/Projects/undercut/packages/undercut/babel.config.js from /home/spyke/Projects/undercut/node_modules/@babel/core/lib/config/files/configuration.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename babel.config.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/spyke/Projects/undercut/packages/undercut/package.json.

Describe the solution you'd like

The solution should be renaming babel.config.js into babel.config.cjs, but it isn't supported by Babel yet.

Describe alternatives you've considered

I've considered ignoring this warning, but it is annoying.

Teachability, Documentation, Adoption, Migration Strategy

The solution has no braking changes. Documentation changes are minimal: adding another possible name for config file.

Activity

  1. babel-bot commented on Oct 23, 2019

    @babel-bot
    Collaborator

    Hey @the-spyke! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

    If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

  2. JLHwung commented on Oct 23, 2019

    @JLHwung
    Contributor

    As a workaround, you can pass --config-file to @babel/cli:

    babel --config-file ./packages/undercut/babel.config.cjs ./packages/undercut
    
  3. added
    outdated
    on Feb 3, 2020
  4. locked as resolved and limited conversation to collaborators on Feb 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Has PRoutdated

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions