Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for .cjs config files #10599

Merged
merged 4 commits into from Nov 3, 2019

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Oct 23, 2019

Q                       A
Fixed Issues? Fixes #10595
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature? Yes
Tests Added + Pass? Yes
Documentation PR Link babel/website#2106
Any Dependency Changes?
License MIT

The three commits should be reviewed one by one:

  • 6c80fa1 refactors a bit the config loading logic, since the check to disallow duplicated files was triplicated in three different places
  • 6aa196c adds support for babel.config.cjs and .babelrc.js
  • db4f8a4 adds the necessary tests and refactors them to use test.each (since we are testing the same things for each config file)

I'm marking this PR as High Priority because we need it to support using Babel in packages using "type": "module" in their package.json. Note that while ES modules are still experimental in Node 13.0.0, they will be enabled by default in 13.1.0 (https://twitter.com/jasnell/status/1184265267951493120).

@nicolo-ribaudo nicolo-ribaudo added PR: New Feature 🚀 A type of pull request used for our changelog categories Priority: High area: node area: config labels Oct 23, 2019
@nicolo-ribaudo nicolo-ribaudo added this to the v7.7.0 milestone Oct 23, 2019
const cwd = await fs.promises.mkdtemp(os.tmpdir() + path.sep + name);
const tmp = name => path.join(cwd, name);
const config = name =>
fs.promises.copyFile(fixture("config-files-templates", name), tmp(name));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fs.promises is not supported until 10.x

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right 🤦‍♂️

@JLHwung JLHwung added PR: Needs Docs PR: Needs Review A pull request awaiting more approvals labels Oct 24, 2019
@nicolo-ribaudo
Copy link
Member Author

Docs added to babel/website#2106

@nicolo-ribaudo nicolo-ribaudo changed the base branch from feat-7.7/config-files to master October 29, 2019 18:38
const ROOT_CONFIG_FILENAMES = [
BABEL_CONFIG_JS_FILENAME,
BABEL_CONFIG_JSON_FILENAME,
"babel.config.js",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about .mjs? Would that be an issue in the future?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't support configurations which must be loaded asynchronously (like es modules) yet.

@nicolo-ribaudo
Copy link
Member Author

@fisker In our tests there isn't that warning 🤔

https://travis-ci.com/babel/babel/jobs/250695663

@JLHwung
Copy link
Contributor

JLHwung commented Nov 3, 2019

@fisker fs.promises is marked as stable in v10.17.0: nodejs/node@21604db

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Feb 3, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Feb 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: config area: node outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Needs Review A pull request awaiting more approvals PR: New Feature 🚀 A type of pull request used for our changelog categories Priority: High
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Loading .cjs config files on Node 13
5 participants