Skip to content

feat: allow for @cypress/webpack-batteries-included-preprocessor to fully resolve the tsconfig.json for compilerOptions in ts-loader (v15) #31590

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

Open
wants to merge 3 commits into
base: release/15.0.0
Choose a base branch
from

Conversation

AtofStryker
Copy link
Contributor

@AtofStryker AtofStryker commented Apr 25, 2025

fully resolves the user tsconfig compiler options instead of trying to infer the tsconfig.json implicitly

Additional details

Passes in the discovered user's tsconfig.json compilerOptions from the cypress/ directory into ts-loader. This change is intended to give users more power of the cypress webpack preprocessor.

This is being flagged as a feature here, but is considered disruptive as it means users need to fully specify their tsconfig.json compatibility to work correctly with Cypress. This can be seen with the moduleResolution: "node" updates in @cypress/webpack-dev-server and @cypress/vite-dev-server as the default resolution is "classic" and doesn't work with "resolveJsonModule". For most user's, this should be a passive change.

Regardless of passed in options, sourceMap=true is always overridden in the @cypress/webpack-preprocessor since Cypress needs source maps to deliver accurate snapshots and code frames.

Steps to test

use the pre-release binaries in 484c2eb#comments to run against some sample tsconfigs in the cypress/ directory of your project. If you run DEBUG=cypress:webpack-batteries-included-preprocessor npx cypress open you should now be able to see which tsconfig compilerOptions are being passed in.

How has the user experience changed?

Previously, @cypress/webpack-batteries-included-preprocessor would use ts-loader without specifying any type of compilerOptions, which will try to imply the compilerOptions from the relatively resolved tsconfig.json of the file/process, which may not be correct as we want to use the defined tsconfig.json in the cypress/ directory, or project root if one does not exist.

With this change, we are now make sure to use the user's defined tsconfig.json compilerOptions to process the file.

Additionally, if processing TypeScript files without a tsconfig.json in the project root or in the cypress directory, the preprocessor now throws an error. This is to improve the error thrown in #18938, but does not completely close the issue

PR Tasks

Copy link

cypress bot commented Apr 25, 2025

cypress    Run #62346

Run Properties:  status check failed Failed #62346  •  git commit 4e6f1170d9: empty commit to run ci
Project cypress
Branch Review feat/wbip_full_resolve_ts_config
Run status status check failed Failed #62346
Run duration 19m 25s
Commit git commit 4e6f1170d9: empty commit to run ci
Committer Bill Glesias
View all properties for this run ↗︎

Test results
Tests that failed  Failures 2
Tests that were flaky  Flaky 2
Tests that did not run due to a developer annotating a test with .skip  Pending 27
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 746
View all changes introduced in this branch ↗︎
UI Coverage  62.34%
  Untested elements 27  
  Tested elements 48  
Accessibility  96.15%
  Failed rules  0 critical   4 serious   1 moderate   0 minor
  Failed elements 151  

Tests for review

Failed  cypress\e2e\studio\studio.cy.ts • 2 failed tests • app-e2e

View Output

Test Artifacts
Cypress Studio > cloud studio > opens studio panel to new test when clicking on studio button (from the app) next to url Test Replay Screenshots
Cypress Studio > cloud studio > opens a cloud studio session with AI enabled Test Replay Screenshots
Flakiness  cypress\e2e\runner\ct-framework-errors.cy.ts • 1 flaky test • app-e2e

View Output

Test Artifacts
Next.js > error conditions Test Replay Screenshots
Flakiness  cypress\e2e\studio\studio.cy.ts • 1 flaky test • app-e2e

View Output

Test Artifacts
Cypress Studio > cloud studio > immediately loads the studio panel Test Replay Screenshots

@AtofStryker AtofStryker force-pushed the feat/wbip_full_resolve_ts_config branch 2 times, most recently from a65ff55 to 0bc3d98 Compare April 28, 2025 14:04
@AtofStryker AtofStryker self-assigned this Apr 28, 2025
@AtofStryker AtofStryker force-pushed the feat/wbip_full_resolve_ts_config branch 3 times, most recently from 7007730 to fe0e7c6 Compare April 30, 2025 18:18
@AtofStryker AtofStryker force-pushed the feat/wbip_full_resolve_ts_config branch 2 times, most recently from 6ed4b6e to fe0e7c6 Compare May 2, 2025 18:38
@AtofStryker AtofStryker changed the title feat (DRAFT): allow for @cypress/webpack-batteries-included-preprocessor to fully resolve the tsconfig.json for compilerOptions in ts-loader feat: allow for @cypress/webpack-batteries-included-preprocessor to fully resolve the tsconfig.json for compilerOptions in ts-loader May 2, 2025
@AtofStryker AtofStryker force-pushed the feat/wbip_full_resolve_ts_config branch 3 times, most recently from b7a62ac to 61055e6 Compare May 6, 2025 17:44
@jennifer-shehane jennifer-shehane changed the title feat: allow for @cypress/webpack-batteries-included-preprocessor to fully resolve the tsconfig.json for compilerOptions in ts-loader feat: allow for @cypress/webpack-batteries-included-preprocessor to fully resolve the tsconfig.json for compilerOptions in ts-loader (v15) May 6, 2025
@AtofStryker AtofStryker force-pushed the feat/wbip_full_resolve_ts_config branch from c61cca7 to 4e6f117 Compare May 12, 2025 17:28
@jennifer-shehane jennifer-shehane self-requested a review May 12, 2025 18:10
Copy link
Member

@jennifer-shehane jennifer-shehane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I encountered an unusual error with a project with a ts file and no tsconfig that requires looking into. Slack thread

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.

2 participants