Repository navigation
Convert CLI options loader to ESM - #6339
Open
mark-wiemer with Copilot wants to merge 2 commits into
Open
mark-wiemer with Copilot wants to merge 2 commits into
mark-wiemer with Copilot wants to merge 2 commits into
Conversation
|
Co-authored-by: mark-wiemer <7833360+mark-wiemer@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Convert remaining lib/cli files to ESM
Convert CLI options loader to ESM
Sep 16, 2026
5 tasks done
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The unit test must use an ESM-compatible mocking approach instead of synchronous rewiremock.proxy(...).
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Converts the CLI options loader from CommonJS to native ESM while updating consumers, tests, and package publication.
Changes:
- Rewrites the options loader using ESM syntax.
- Updates CLI bootstrap imports and test resolution.
- Publishes
.mjsfiles.
| File | Summary |
|---|---|
test/node-unit/cli/options.spec.js |
Updates the options module path |
package.json |
Includes .mjs files in published contents |
lib/cli/options.mjs |
ESM options loader implementation |
lib/cli/cli.js |
Updates the loader import |
bin/mocha.js |
Updates the CLI bootstrap import |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| const { proxy } = rewiremock; | ||
|
|
||
| const modulePath = require.resolve("../../../lib/cli/options.cjs"); | ||
| const modulePath = require.resolve("../../../lib/cli/options.mjs"); |
mark-wiemer
marked this pull request as ready for review
October 8, 2026 14:47
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The CLI option-loading path was one of the remaining CJS holdouts in the internal ESM migration, leaving the runtime boot flow split between module systems. This change converts the remaining option loader to native ESM without changing the user-visible CLI/config behavior.
Summary
lib/cli/options.cjstolib/cli/options.mjsloadOptions/loadRc/loadPkgRcbehavior while aligning with the repo’s ESM migration conventionsChanges
lib/cli/options.mjs: rewrites the module to ESM withimport/exportsyntax and JSON import semanticslib/cli/cli.js: switches the loader import to the ESM modulebin/mocha.js: switches the CLI bootstrap import to the ESM moduletest/node-unit/cli/options.spec.js: updates resolution to the new ESM pathpackage.json: includeslib/**/*.mjsin the published files list so the module is shipped correctlyThis keeps the CLI config-loading workflow intact while completing the remaining ESM conversion in the CLI bootstrap path.
lib/cli/files to ESM #5967