Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add exports to package.json for Node.JS v20.19.0 #940

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aloisklink
Copy link

Add Node.JS export conditions to package.json, so that the examples of things like import '@cypress/code-coverage/support' continue to work in Node.JS v20.19.0.

I've added package.json too since it's theoretically possible somebody did require("@cypress/code-coverage/package.json"), so we should support that too.

See: https://nodejs.org/api/packages.html#exports

The bug this fixes

I'm not sure why, but import "@cypress/code-coverage/task" in a cypress.config.ts file seems to break in Node.JS v20.19.0, despite working before, with:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './task' is not defined by "exports" in /node_modules/@cypress/code-coverage/package.json imported from /cypress.config.js

I think this is probably a bug in ts-node/esm, since it looks like there's a similar issue with @swc-node/register/esm-register: nodejs/node#57536

Still, it's worth changing this package so that import '@cypress/code-coverage/support' works in ESM too!

Add Node.JS export conditions to `package.json`, so that the examples of
things like `import '@cypress/code-coverage/support'` continue to work
in Node.JS v20.19.0.

I believe I've added `package.json` too since it's theoretically
possible somebody did `require("@cypress/code-coverage/package.json")`,
so we should support that too.

See: https://nodejs.org/api/packages.html#exports
@CLAassistant
Copy link

CLAassistant commented Mar 25, 2025

CLA assistant check
All committers have signed the CLA.

@cypress-app-bot
Copy link

aloisklink added a commit to aloisklink/mermaid that referenced this pull request Mar 25, 2025
Node.JS v20.19.0 breaks `import '@cypress/code-coverage/task'` in the
`cypress.config.ts` for some reason (this is probably due to the new
`experimental-require-module` feature that is enabled by default in
Node.JS v20.19.0).

As a work-around, we can change this to
`@cypress/code-coverage/task.js`.

See: cypress-io/code-coverage#940
See: https://nodejs.org/en/blog/release/v20.19.0
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.

None yet

3 participants