-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
feat: adding module support for invoking cypress.config.mjs, .cjs, .ts #20554
Conversation
Thanks for taking the time to open a PR!
|
Test summaryRun details
View run in Cypress Dashboard ➡️ Flakiness
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job getting this through so quickly. I left some comments, most important one is adding the watcher to a cypress.config.mjs
if it exists.
system-tests/projects/config-cjs-and-esm/config-with-ts-module/cypress.config.ts
Outdated
Show resolved
Hide resolved
b999185
to
08510bc
Compare
Did you try it with UNIFY-1135 ? |
12a1447
to
705408c
Compare
…cypress into fix/typescript-module-config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all my blocking comments are ✔️ so seems fine - added 1 more question. Can we please assign someone from E2E to review this too?
"import": "./index.mjs", | ||
"require": "./index.js" | ||
}, | ||
"./package.json": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: what does this do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://nodejs.org/api/packages.html#package-entry-points allows package.json to be accessible. See "Package Entry Points"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding this!
if (err.stack.includes(`Cannot find package 'esbuild'`)) { | ||
debug(`User doesn't have esbuild. Going to use native node imports.`) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we expect this to work? Should we just throw an error that's like
"Hey, Cypress depends on esbuild
for ESM support, please install it and try again"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have it as a "real" dependency and only use it if typescript is detected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works fine for all TS projects where type != module. We don't need to fail -- we can just fall back.
if (legacyPlugins && typeof legacyPlugins.default === 'function') { | ||
legacyPlugins = legacyPlugins.default | ||
} | ||
// Config file loading of modules is tested within |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This got butchered during the rebase, I put all the "legacy config" stuff at the bottom.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I merged in 10.0-release and resolved the conflicts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great, nice tests too 👍
Summary
Adds support for Cypress Config files to work with modules. Uses @egoist 's bundle-require which was created for loading library config files like
vite.config.ts
We now support the following config file types:
cypress.config.mjs
cypress.config.cjs
cypress.config.js
with "type": "module"cypress.config.ts
with "type": "module"We now support ESM inside of plugins hooks (setupNodeEvents + devServer)
Closes:
Changes made
index.mjs
,cli/package.json
)bundle-require
to execute Cypress Config