Closed
Description
Describe the bug
Not exactly about ESM, but a symptom of the way we've made the package "hybrid".
Some require
statements that work fine when everything's CommonJS don't work with new ESM-aware Node versions and our module config.
To Reproduce
Steps to reproduce the behavior:
- Use
@cucumber/cucumber@8.0.0-rc.2
and@cucumber/pretty-formatter
- Do a test run with
--format @cucumber/pretty-formatter
Expected behavior
Normal test run with output from the formatter.
Actual behaviour
Error: Cannot find module '/Users/davidgoss/Projects/my-project/node_modules/@cucumber/cucumber/lib/formatter/helpers.js'
Additional context
The stack trace leads to this require statement in the pretty formatter's compiled code:
const helpers_1 = require("@cucumber/cucumber/lib/formatter/helpers");
We have this mapping in our package.json
:
{
"exports": {
".": {
"import": "./lib/wrapper.mjs",
"require": "./lib/index.js"
},
"./lib/*": {
"require": "./lib/*.js"
},
"./package.json": "./package.json"
},
}
The actual file it should be importing is:
node_modules/@cucumber/cucumber/lib/formatter/helpers/index.js
We'll need to either improve this exports mapping or rethink how we're accomodating ESM.