Thanks to visit codestin.com
Credit goes to github.com

Skip to content

๐Ÿ›  Repo: Switch from CJS to ESM internallyย #5400

@JoshuaKGoldberg

Description

@JoshuaKGoldberg

Tooling Suggestion Checklist

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 was 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.

Metadata

Metadata

Type

No type

Projects

Status

In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions