-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Tooling Suggestion Checklist
- I have tried restarting my IDE and the issue persists.
- I have pulled the latest
main
branch of the repository. - I have read and agree to Mocha's Code of Conduct and Contributing Guidelines
- I have searched for related issues and issues with the
faq
label, but none matched my issue. - I want to provide a PR to resolve this
Overview
Mocha's source code is written in a legacy CommonJS (CJS) style right now. That means 'use strict'
in source files, const ... = require(...)
, module.exports
, etc.
Moving to ECMAScript Modules (ESM) would allow the code to integrate better with more modern dev tooling. Static analysis tools such as ESLint and TypeScript are better able to analyze ESM, for example: which will help with #4154 and #4228.
Also I find ESM to be a cleaner syntax. It's more semantically precise! 🙂
Suggestion: let's migrate internally from CJS to ESM?
Additional Info
This is blocked on #5358: bumping the minimum Node.js version to one that supports require(esm).
I suspect this should land as a part of Mocha 12 (#5357). Although it shouldn't be a breaking change on its own, it's very likely some users out there are depending on some internal structuring quirk. Having this be part of the 12 beta for a while will help test it out. And having it be part of a major will help shield us from protests of semver breakage.