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

[CT] Fix Vite 5 CJS Deprecation Warning and Prepare for Vite 6 #28373

Open
sodatea opened this issue Nov 21, 2023 · 4 comments
Open

[CT] Fix Vite 5 CJS Deprecation Warning and Prepare for Vite 6 #28373

sodatea opened this issue Nov 21, 2023 · 4 comments
Labels
CT Issue related to component testing prevent-stale mark an issue so it is ignored by stale[bot]

Comments

@sodatea
Copy link
Contributor

sodatea commented Nov 21, 2023

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 root tsconfig.json and "type": "module" being present in package.json.

Desired behavior

Should not show the CJS warning because vite.config.ts should be treated as an ES module when type: "module" presents.

Test code to reproduce

git clone https://github.com/sodatea/vite-5-cypress-reproduction
cd vite-5-cypress-reproduction
pnpm i
pnpm test:unit

The following warning will be printed:

The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.

and

We detected that you have versions of dependencies that are not officially supported:

 - `vite`. Expected ^2.0.0 || ^3.0.0 || ^4.0.0, found 5.0.0.

If you're experiencing problems, downgrade dependencies and restart Cypress.

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.

@sodatea
Copy link
Contributor Author

sodatea commented Nov 21, 2023

IMO, getting rid of ts-node may be a better option here. Because there are other well-known issues of this tool.
For example, it doesn't support solution-style tsconfigs, forcing us to specify a compilerOptions.module option in the root tsconfig.json, even though that field doesn't mean anything for any other tool. This is not a good DX.

@jennifer-shehane jennifer-shehane added the CT Issue related to component testing label Nov 21, 2023
@MikeMcC399
Copy link
Contributor

The warning

The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.

links also to

@cypress-app-bot
Copy link
Collaborator

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.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label Jun 7, 2024
@MikeMcC399
Copy link
Contributor

@jennifer-shehane jennifer-shehane added prevent-stale mark an issue so it is ignored by stale[bot] and removed stale no activity on this issue for a long period labels Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CT Issue related to component testing prevent-stale mark an issue so it is ignored by stale[bot]
Projects
None yet
Development

No branches or pull requests

4 participants