Description
Context
Cucumber, as a set of JavaScript libraries, is in a bit of a messy state when it comes to CommonJS vs ESM:
- Some libraries remain CommonJS, meaning they are increasingly limited in what dependencies they can adopt/upgrade
- Some libraries have a dual module format, which still suffers from the above issue but adds complexity
- Some libraries are ESM only already (just
react-components
to my knowledge, which is fine because it only targets browser bundlers)
Switching all libraries to ESM only would simplify things and remove constraints on using ESM-only dependencies. This has not been a realistic prospect because userland code will be require()
ing our libraries, which doesn't work.
New developments
However, Node.js now supports require(esm)
(as long as the target module has no top-level awaits). This has been backported to 20.x without a flag in https://github.com/nodejs/node/releases/tag/v20.19.0.
This means that for Node.js 20.x and above, making our libraries ESM only should not cause any issues.
Proposal
When we drop Node.js 18.x support (it will get EOL'd on 30 April 2025), change the libraries to be ESM-only. This will need a test in each repo to prove it works, and catch regressions if e.g. a transitive dependency were to introduce a top-level await.
Metadata
Metadata
Assignees
Type
Projects
Status