-
-
Couldn't load subscription status.
- Fork 3.1k
feat: ESM configuration file #5397
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
base: main
Are you sure you want to change the base?
Conversation
lib/cli/config.js
Outdated
| * @returns {Object} Parsed config object | ||
| */ | ||
| exports.loadConfig = filepath => { | ||
| const packageJson = require(path.resolve(utils.cwd(), 'package.json')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if there's a better / more idiomatic way in Mocha to get the user's package.json file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would personally use something like package-up
But, determining whether the caller is CJS or ESM can be more tricky than that. My instinct is it'd be best to not add in specific logic for either. Using require(esm), we can do something simpler like packageJson.default ?? packageJson and call it a day.
|
👋 @thescientist13 just checking in, are you waiting on us for anything? Now that #5358 is merged, this shouldn't have to worry about |
66732d2 to
7613e58
Compare
|
hey @JoshuaKGoldberg , thanks for checking in! Not waiting on anything per se, was just waiting to see what would happen with that other PR. I just rebased against main and pushed that up here with your feedback suggestion from earlier, so I can work on tests / docs if that's good with you. |
|
Had some intermittent test failures locally, but none of them seemed related to the CLI changes here, so throwing this up to see what happens. 😅 |
PR Checklist
status: accepting prsOverview
Introduces the ability to use ESM configuration files for Mocha, leveraging the
require(ESM)capability of Node >= 20.19.0TODO
Per my understanding of support
require(ESM)is so far only in >= 20.19.0, so not sure how this will fare with test cases running on Node 18, and or if this is something to just call out in the documentation? Not sure if will get backported to 18.x at this point as it is EOL now...Either way, let me know your thoughts on the current implementation and the implications of Node support. Happy to add a test case / docs once I make sure this changeset is heading in the right direction. 🫡