-
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
[CT] Fix Vite 5 CJS Deprecation Warning and Prepare for Vite 6 #28373
Comments
IMO, getting rid of |
The warning
links also to |
This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided. |
|
currently caused by require.resolve. // "vite-dev-server" is bundled in the binary, so we need to require.resolve "vite"
// from root of the active project since we don't bundle vite internally but rather
// use the version the user has installed
export function getVite (config: ViteDevServerConfig): Vite {
try {
const viteImportPath = require.resolve('vite', { paths: [config.cypressConfig.projectRoot] })
debug('resolved viteImportPath as %s', viteImportPath)
return require(viteImportPath)
} catch (err) {
throw new Error(`Could not find "vite" in your project's dependencies. Please install "vite" to fix this error.\n\n${err}`)
}
} |
Any way to resolve this? |
It looks like vite 6 has not yet removed the vite cjs API yet, so this does not block vite 6 support. For Cypress to get rid of using the cjs API requires some involved steps
from "module": "commonjs",
"moduleResolution": "node", to "module": "ESNext",
"moduleResolution": "node", This will make the package compile down to ESM.
We would also need to make sure moving the plugin manager over to ESM could still work with end user cjs plugins. Either way, the work here is fairly involved. |
Current behavior
When using Cypress Component Testing with Vite 5, if
vite.config.ts
is used, a CJS Node API deprecation warning will always appear, despite"module": "NodeNext"
or"module": "ESNext"
being specified in the roottsconfig.json
and"type": "module"
being present inpackage.json
.Desired behavior
Should not show the CJS warning because
vite.config.ts
should be treated as an ES module whentype: "module"
presents.Test code to reproduce
The following warning will be printed:
and
The latter issue has already been tracked at #28347
Cypress Version
13.5.1
Node version
v18.18.2
Operating System
macOS 14.1
Debug Logs
No response
Other
I guess this is because of the limitation of
ts-node
that Cypress uses underlyingly to load the configuration files:TypeStrong/ts-node#1791 (comment)
Considering Vite 6 will drop CJS Node API, I think Cypress needs to either work around this limitation or move away from
ts-node
as early as possible.The text was updated successfully, but these errors were encountered: