Skip to content

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

Merged
mark-wiemer merged 36 commits into
mochajs:mainfrom
mark-wiemer:root-package-type-module
Jun 19, 2026
Merged

mark-wiemer merged 36 commits into
mochajs:mainfrom
mark-wiemer:root-package-type-module

Conversation

@mark-wiemer

@mark-wiemer mark-wiemer commented Jun 17, 2026 •

Copy link
Copy Markdown
Member

PR Checklist

Overview

My version of #6034, rebased to reduce merge conflicts and respect Josh's fork

  • Changes package.json to "type": "module" so Mocha is now an ESM-first package (users can still require('mocha'))
  • Renames js files to cjs and mjs files to js
  • Revert options.mjs to CJS (options.cjs) and some related files back to CJS due to rewiremock usage and low ROI for implementing (risky!) replacement. Turns out options.spec.mjs wasn't running in main (glob pattern) and when we made it run as ESM, it failed miserably!
  • Fixes an internal bug with running nested tests in the unit folder, adding 1 test file (all tests pass)

@mark-wiemer
mark-wiemer force-pushed the root-package-type-module branch from b79b5cf to f6be57c Compare June 17, 2026 03:06
@codecov

codecov Bot commented Jun 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.27273% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.25%. Comparing base (7c9b004) to head (774c48b).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.wallaby.cjs 0.00% 1 Missing ⚠️
bin/mocha.js 0.00% 1 Missing ⚠️
lib/cli/index.cjs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6078      +/-   ##
==========================================
+ Coverage   78.83%   82.25%   +3.41%     
==========================================
  Files          63       61       -2     
  Lines        4546     4564      +18     
  Branches      989      958      -31     
==========================================
+ Hits         3584     3754     +170     
+ Misses        962      810     -152     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mark-wiemer

This comment was marked as outdated.

Comment thread docs/package-lock.json Resolved
Comment thread test/integration/compiler-cjs.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 eslint.config.cjs Resolved
Comment thread eslint.config.cjs Resolved
Comment thread lib/cli/node-flags.cjs Resolved
Comment thread package.json Resolved
Comment thread package.json Resolved
@mark-wiemer
mark-wiemer marked this pull request as ready for review June 18, 2026 03:03

@JoshuaKGoldberg JoshuaKGoldberg 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.

Andy Richter on Conan going 'WOOT WOOT!' excitedly and lightly pumping one fist

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