Skip to content

feat!: change root package.json type to module - #6034

Closed
JoshuaKGoldberg wants to merge 4 commits into
mochajs:mainfrom
JoshuaKGoldberg:root-package-type-module
Closed

JoshuaKGoldberg wants to merge 4 commits into
mochajs:mainfrom
JoshuaKGoldberg:root-package-type-module

Conversation

@JoshuaKGoldberg

Copy link
Copy Markdown
Member

PR Checklist

Overview

At long last:

  • package.json's type is switched from "commonjs" to "module"
  • Files are renamed from (.js, .mjs) to (.cjs, .js)

The only "backwards" change here is lib/cli/options.mjs -> lib/cli/options.cjs. It's used in requiremock tests and we haven't migrated to a mocker that supports ESM yet.

💖

@JoshuaKGoldberg

Copy link
Copy Markdown
Member Author

Build failures seem to just be codecov/codecov-action#1876.

@mark-wiemer

Copy link
Copy Markdown
Member

Tests are passing on my Windows machine, Node 20.19.0, with the patched #6040 (ref mark-wiemer@08f921b), no unusual output aside from expected EBADENGINE when installing docs dependencies :)

@mark-wiemer

Copy link
Copy Markdown
Member

Build failures seem to just be codecov/codecov-action#1876.

That bug is old and about random failures, which matches #6036 . I've created a new bug for consistent failures today: #6042 .

@mark-wiemer

Copy link
Copy Markdown
Member

Test failed on my Windows machine with Node v22.12.0:

  346 passing (3m)
  2 pending
  1 failing

  1) FIFO support
       should accept a test passed as a FIFO:
     Error: Couldn't parse JSON: Unexpected token '(', "(node:3652"... is not valid JSON

Original result output: (node:3652) ExperimentalWarning: CommonJS module C:\Users\markw\my-stuff\hello-hello\packages\mocha\packages\mocha\lib\cli\options.cjs is loading ES Module C:\Users\markw\my-stuff\hello-hello\packages\mocha\packages\mocha\lib\cli\one-and-dones.js using require().    
Support for loading ES Module in require() is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
{
  "stats": {
    "suites": 1,
    "tests": 1,
    "passes": 1,
    "pending": 0,
    "failures": 0,
    "start": "2026-06-07T03:12:02.281Z",
    "end": "2026-06-07T03:12:02.282Z",
    "duration": 1
  },
  "tests": [
    {
      "title": "should pass",
      "fullTitle": "suite from FIFO should pass",
      "file": "C:\\Users\\markw\\AppData\\Local\\Temp\\mocha-test-fifo-CH1ftF\\fifo-1",
      "duration": 0,
      "currentRetry": 0,
      "speed": "fast",
      "err": {}
    }
  ],
  "pending": [],
  "failures": [],
  "passes": [
    {
      "title": "should pass",
      "fullTitle": "suite from FIFO should pass",
      "file": "C:\\Users\\markw\\AppData\\Local\\Temp\\mocha-test-fifo-CH1ftF\\fifo-1",
      "duration": 0,
      "currentRetry": 0,
      "speed": "fast",
      "err": {}
    }
  ]
}
      at toJSONResult (test\integration\helpers.cjs:185:11)
      at invokeMocha.stdio (test\integration\fifo.spec.cjs:44:26)
      at ChildProcess.<anonymous> (test\integration\helpers.cjs:355:5)
      at ChildProcess.emit (node:events:524:28)
      at maybeClose (node:internal/child_process:1101:16)
      at ChildProcess._handle.onexit (node:internal/child_process:304:5)



ERROR: "test-node:integration" exited with 1.
ERROR: "test-node" exited with 1.

I'm going to pause my review now given this is in draft state and you're probably aware of some of these issues :) Happy to continue running Windows- or Linux-specific checks as needed, of course :) thanks for leading this one!

@mark-wiemer mark-wiemer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Partial review given draft state, matches what I want though! Mostly! ;)

Comment thread .github/ISSUE_TEMPLATE/01-bug.yml Resolved
Comment thread lib/browser/highlight-tags.js Resolved
@JoshuaKGoldberg

Copy link
Copy Markdown
Member Author

Ha yeah, I figured I'd come back to this after the Codecov issues were done.

@mark-wiemer

Copy link
Copy Markdown
Member

See also my PR: #6078

Comment thread test/integration/options/ui.spec.cjs Resolved
Comment thread test/integration/helpers.cjs Resolved
Comment thread test/integration/helpers.cjs Resolved
Comment thread test/node-unit/cli/options.spec.js Resolved
Comment thread eslint.config.cjs Resolved
Comment thread test/integration/compiler-cjs.spec.cjs Resolved
@JoshuaKGoldberg

Copy link
Copy Markdown
Member Author

Closing out in favor of Mark's in-progress PR.

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: Switch from CJS to ESM internally

2 participants