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

Spurious TypeScript warnings in monorepo with JavaScript component testing project #30915

Open
MikeMcC399 opened this issue Jan 18, 2025 · 0 comments

Comments

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Jan 18, 2025

Current behavior

Running Cypress component testing in a Vite v5 based JavaScript project in a monorepo, where TypeScript is a transient dependency only in the root of the monorepo, results in additional warnings if the dependencies in the repo root are also installed:

(node:5542) ExperimentalWarning: --experimental-loader may be removed in the future; instead use register():
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("file%3A///home/mike/.cache/Cypress/14.0.0/Cypress/resources/app/node_modules/ts-node/esm/transpile-only.mjs", pathToFileURL("./"));'
(Use node --trace-warnings ... to show where the warning was created)
(node:5542) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use node --trace-deprecation ... to show where the warning was created)

Desired behavior

The results of running Cypress component testing in a monorepo JavaScript project should be independent of whether the TypeScript dependencies in the root of the repo have been installed or not.

Test code to reproduce

Execute first:

git clone https://github.com/cypress-io/github-action
cd github-action
git clean -xfd # if repeating tests
npm ci
cd examples/component-tests
npm ci
npm test

which shows multiple node warnings (see above, and Debug Logs below), then execute:

rm -rf ../../node_modules
npm test

and confirm only the CJS deprecation warning is output:

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.

Cypress Version

14.0.0

Node version

v22.13.0 LTS

Operating System

Ubuntu 24.04.1 LTS

Debug Logs

$ npm test

> [email protected] test
> cypress run --component


DevTools listening on ws://127.0.0.1:40257/devtools/browser/ced1c3dd-9c2a-40a8-94b8-12afea482130
(node:5542) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("file%3A///home/mike/.cache/Cypress/14.0.0/Cypress/resources/app/node_modules/ts-node/esm/transpile-only.mjs", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:5542) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
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.

====================================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        14.0.0                                                                         │
  │ Browser:        Electron 130 (headless)                                                        │
  │ Node Version:   v22.13.0 (/home/mike/n/bin/node)                                               │
  │ Specs:          1 found (Stepper.cy.jsx)                                                       │
  │ Searched:       **/*.cy.{js,jsx,ts,tsx}                                                        │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘

with root dependencies installed:

  cypress:lifecycle:ProjectConfigIpc fork child process { CHILD_PROCESS_FILE_PATH: '/home/mike/.cache/Cypress/14.0.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/require_async_child.js', configProcessArgs: [ '--projectRoot', '/home/mike/github/cypress-io/github-action/examples/component-tests', '--file', '/home/mike/github/cypress-io/github-action/examples/component-tests/cypress.config.js' ], childOptions: { stdio: 'pipe', cwd: '/home/mike/github/cypress-io/github-action/examples/component-tests', execPath: '/home/mike/n/bin/node' } } +0ms
  cypress:lifecycle:ProjectConfigIpc found typescript in /home/mike/github/cypress-io/github-action/examples/component-tests +3ms
  cypress:lifecycle:ProjectConfigIpc using --experimental-specifier-resolution=node with --loader file:///home/mike/.cache/Cypress/14.0.0/Cypress/resources/app/node_modules/ts-node/esm/transpile-only.mjs +3ms
  cypress:lifecycle:ProjectConfigIpc detected node version 22.13.0, adding --no-experimental-detect-module option to child_process NODE_OPTIONS. +1ms
  cypress:lifecycle:ProjectConfigIpc detected node version 22.13.0, adding --no-experimental-require-module option to child_process NODE_OPTIONS. +0ms
  cypress:lifecycle:ProjectConfigIpc trigger the load of the file +17ms
(node:6747) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("file%3A///home/mike/.cache/Cypress/14.0.0/Cypress/resources/app/node_modules/ts-node/esm/transpile-only.mjs", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:6747) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
  cypress:lifecycle:ProjectConfigIpc loadConfig:reply +729ms
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.

when root dependencies not installed:

  cypress:lifecycle:ProjectConfigIpc fork child process { CHILD_PROCESS_FILE_PATH: '/home/mike/.cache/Cypress/14.0.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/require_async_child.js', configProcessArgs: [ '--projectRoot', '/home/mike/github/cypress-io/github-action/examples/component-tests', '--file', '/home/mike/github/cypress-io/github-action/examples/component-tests/cypress.config.js' ], childOptions: { stdio: 'pipe', cwd: '/home/mike/github/cypress-io/github-action/examples/component-tests', execPath: '/home/mike/n/bin/node' } } +0ms
  cypress:lifecycle:ProjectConfigIpc no typescript found, just use regular Node.js +3ms
  cypress:lifecycle:ProjectConfigIpc trigger the load of the file +12ms
  cypress:lifecycle:ProjectConfigIpc loadConfig:reply +468ms
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.

Other

Related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants