Skip to content

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

Draft
mark-wiemer wants to merge 11 commits into
mochajs:mainfrom
mark-wiemer:root-package-type-module
Draft

feat!: change root package.json type to module#6078
mark-wiemer wants to merge 11 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 we Mocha is now an ESM-first package
  • Renames js files to cjs and mjs files to js
  • Revert options.mjs to CJS (options.cjs) due to rewiremock usage and low ROI for implementing (risky!) replacement

  • change ESM files back to using mjs for clarity? Need alignment with Josh as other maintainer
  • several files in lib/cli were reverted to CJS, was that intentional? Only options.mjs is called out in description.
  • test/integration/compiler-cjs.spec.cjs ?
  • need lint rule to ensure js extensions aren't used in spaces where only cjs is expected, e.g. npm run test-node:unit
  • comments in feat!: change root package.json type to module #6034

@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.15%. Comparing base (7c9b004) to head (bbdeaf4).

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.15%   +3.31%     
==========================================
  Files          63       62       -1     
  Lines        4546     4566      +20     
  Branches      989      991       +2     
==========================================
+ Hits         3584     3751     +167     
+ Misses        962      815     -147     

☔ 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

Copy link
Copy Markdown
Member Author

Playwright ESM test is failing on Windows + Node 20.19.0, all other tests passing, haven't tested any other OS or Node version yet:

$ npx playwright test
2026-06-16 20:17:34

Running 4 tests using 4 workers

  ✓  1 [chromium] › test\browser\run.spec.mjs:6:3 › browser suite: tdd (351ms)
  ✘  2 [chromium] › test\browser\run.spec.mjs:6:3 › browser suite: esm (297ms)
  ✓  3 [chromium] › test\browser\run.spec.mjs:6:3 › browser suite: qunit (301ms)
  ✓  4 [chromium] › test\browser\run.spec.mjs:6:3 › browser suite: bdd (320ms)


  1) [chromium] › test\browser\run.spec.mjs:6:3 › browser suite: esm ───────────────────────────────

    Error: expect(received).toBeGreaterThan(expected)

    Expected: > 0
    Received:   0

      18 |     );
      19 |
    > 20 |     expect(results.total).toBeGreaterThan(0);
         |                           ^
      21 |   });
      22 | }
      23 |
        at C:\Users\markw\my-stuff\hello-hello\packages\mocha\packages\mocha\test\browser\run.spec.mjs:20:27

    Error Context: test-results\run-browser-suite-esm-chromium\error-context.md

Comment thread docs/package-lock.json
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