Skip to content

Loading .cjs config files on Node 13 #10595

@the-spyke

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Has PRoutdatedA 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