Skip to content

Convert CLI options loader to ESM - #6339

Open
mark-wiemer with Copilot wants to merge 2 commits into
mainfrom
copilot/convert-lib-cli-files-to-esm
Open

mark-wiemer with Copilot wants to merge 2 commits into
mainfrom
copilot/convert-lib-cli-files-to-esm

Conversation

Copilot AI commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

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

    • Converts lib/cli/options.cjs to lib/cli/options.mjs
    • Updates the direct importers to the ESM module path
    • Preserves the existing loadOptions/loadRc/loadPkgRc behavior while aligning with the repo’s ESM migration conventions
  • Changes

    • lib/cli/options.mjs: rewrites the module to ESM with import/export syntax and JSON import semantics
    • lib/cli/cli.js: switches the loader import to the ESM module
    • bin/mocha.js: switches the CLI bootstrap import to the ESM module
    • test/node-unit/cli/options.spec.js: updates resolution to the new ESM path
    • package.json: includes lib/**/*.mjs in the published files list so the module is shipped correctly
import { loadOptions } from "./options.mjs";

This keeps the CLI config-loading workflow intact while completing the remaining ESM conversion in the CLI bootstrap path.

@linux-foundation-easycla

linux-foundation-easycla Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

CLA Not Signed

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
Copilot AI requested a review from mark-wiemer September 16, 2026 12:06
@mark-wiemer
mark-wiemer requested a lite review from Copilot October 1, 2026 00:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 Medium severity

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 .mjs files.
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
mark-wiemer marked this pull request as ready for review October 8, 2026 14:47

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🛠️ Repo: Convert remaining lib/cli/ files to ESM

3 participants