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

fix: update cypress to Typescript 5 #29568

Merged
merged 23 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3b981df
fix: update the monorepo to typescript 5
AtofStryker May 22, 2024
0672d61
chore: updating v8 snapshot cache
May 22, 2024
0d41e9e
chore: updating v8 snapshot cache
May 22, 2024
d7e4715
chore: updating v8 snapshot cache
May 23, 2024
e45d70a
run ci to see problems [run ci]
AtofStryker May 23, 2024
ea3af5c
update vue-tsc and typings that conflict with update
AtofStryker May 23, 2024
bf053a6
regen snapshot
AtofStryker May 23, 2024
8b371ac
fix typescript errors ui test as stack trace behavior has changed
AtofStryker May 23, 2024
15cd2bf
fix server unit tests
AtofStryker May 23, 2024
44ce327
update cy.origin() spec based on stack traces and code frames
AtofStryker May 23, 2024
d0c95cc
update spec to include source map url
AtofStryker May 23, 2024
4a7c8ca
run ci
AtofStryker May 23, 2024
9342cd5
fix check-ts
AtofStryker May 23, 2024
62c449a
chore: fix system tests [run ci]
AtofStryker May 23, 2024
1df72d8
add preprocessor tests to batteries included to exercise new logic
AtofStryker May 24, 2024
5b4650e
run ci
AtofStryker May 24, 2024
273f6df
refactor unit tests to be a bit more dry
AtofStryker May 29, 2024
d3916e9
pin typescript to ~5.4 and adjust config to ignroe deprecations but k…
AtofStryker May 30, 2024
0c9e81e
add changelog entry
AtofStryker May 30, 2024
307eb28
add fixme issue to stack trace mismatches inside evaled context
AtofStryker Jun 4, 2024
93932f9
use import type webpack as webpack as a lib isn't actually invboked i…
AtofStryker Jun 4, 2024
1a559d5
Merge branch 'develop' of github.com:cypress-io/cypress into fix/upda…
AtofStryker Jun 4, 2024
75b8722
fix system test as adding 4 lines of comments impacts the stack trace…
AtofStryker Jun 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ _Released 6/4/2024 (PENDING)_

- Fixed a situation where the Launchpad would hang if the project config had not been loaded when the Launchpad first queries the current project. Fixes [#29486](https://github.com/cypress-io/cypress/issues/29486).
- Pre-emptively fix behavior with Chrome for when `unload` events are forcefully deprecated by using `pagehide` as a proxy. Fixes [#29241](https://github.com/cypress-io/cypress/issues/29241).
- Fixed an issue where `inlineSourceMaps` was still being used when `sourceMaps` was provided in a users typescript config for typescript version 5. Fixes [#26203](https://github.com/cypress-io/cypress/issues/26203).

**Dependency Updates:**

- Updated typescript from `4.7.4` to `5.3.3`. Addressed in [#29568](https://github.com/cypress-io/cypress/pull/29568).

**Misc:**

Expand Down
2 changes: 1 addition & 1 deletion npm/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@angular/core": "^14.2.0",
"@angular/platform-browser-dynamic": "^14.2.0",
"@cypress/mount-utils": "0.0.0-development",
"typescript": "^4.7.4",
"typescript": "~5.4.5",
"zone.js": "~0.11.4"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion npm/cypress-schematic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@types/node": "^18.17.5",
"chai": "4.2.0",
"mocha": "3.5.3",
"typescript": "^4.7.4"
"typescript": "^5.4.5"
},
"peerDependencies": {
"@angular/cli": ">=14",
Expand Down
4 changes: 2 additions & 2 deletions npm/grep/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "Filter tests using substring",
"main": "src/support.js",
"scripts": {
"cy:run": "node ../../scripts/cypress.js run --config specPattern='**/unit.js'",
"cy:open": "node ../../scripts/cypress.js open --e2e -b electron --config specPattern='**/unit.js'",
"cy:run": "node ../../scripts/cypress.js run --config specPattern='**/unit.js'",
"lint": "eslint . --ext .js,.ts"
},
"dependencies": {
Expand All @@ -16,7 +16,7 @@
"devDependencies": {
"cypress-each": "^1.11.0",
"cypress-expect": "^2.5.3",
"typescript": "^4.7.4"
"typescript": "^5.4.5"
},
"peerDependencies": {
"cypress": ">=10"
Expand Down
2 changes: 1 addition & 1 deletion npm/mount-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"rollup": "3.7.3",
"rollup-plugin-dts": "5.0.0",
"rollup-plugin-typescript2": "^0.29.0",
"typescript": "^4.7.4"
"typescript": "^5.4.5"
},
"files": [
"dist"
Expand Down
2 changes: 1 addition & 1 deletion npm/puppeteer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"sinon": "^13.0.1",
"sinon-chai": "^3.7.0",
"ts-node": "^10.9.2",
"typescript": "4.7.4"
"typescript": "5.4.5"
},
"peerDependencies": {
"cypress": ">=13.6.0"
Expand Down
2 changes: 1 addition & 1 deletion npm/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"react-router": "6.0.0-alpha.1",
"react-router-dom": "6.0.0-alpha.1",
"semver": "^7.5.3",
"typescript": "^4.7.4",
"typescript": "~5.4.5",
"vite": "4.5.2",
"vite-plugin-require-transform": "1.0.12"
},
Expand Down
2 changes: 1 addition & 1 deletion npm/react18/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"react-dom": "^16",
"rollup": "3.7.3",
"rollup-plugin-typescript2": "^0.29.0",
"typescript": "^4.7.4"
"typescript": "^5.4.5"
},
"peerDependencies": {
"@types/react": "^18",
Expand Down
2 changes: 1 addition & 1 deletion npm/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"devDependencies": {
"@cypress/mount-utils": "0.0.0-development",
"svelte": "^3.49.0",
"typescript": "^4.7.4"
"typescript": "^5.4.5"
},
"peerDependencies": {
"cypress": ">=10.6.0",
Expand Down
5 changes: 5 additions & 0 deletions npm/vite-dev-server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
"esModuleInterop": true,
/** Allows us to strip internal types sourced from webpack */
"stripInternal": true,
"ignoreDeprecations": "5.0",
/*
* TODO: remove importsNotUsedAsValues after typescript 5.5 and up as it will no longer work. If we want the same behavior
* as importsNotUsedAsValues, we need to use "verbatimModuleSyntax", which will require this package to be an ES Module.
*/
"importsNotUsedAsValues": "error",
Copy link
Contributor

Choose a reason for hiding this comment

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

Removing this preserves the existing behavior without throwing an error - imports that are not used as values will simply be stripped, since verbatimModuleSyntax is not enabled. Is that intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is just oversight on my end. I need to add "verbatimModuleSyntax": true to get the expected behavior. good catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm wondering if we will need to address this separately, since we cant use "verbatimModuleSyntax": true with import syntax inside common js modules. I wonder if we want to make an issue to reword the modules to leverage "verbatimModuleSyntax": true since there isn't anything that leads me to believe this is an issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we have any polyfills or other content where this would be an issue but not entirely sure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder if we just want to pin to ~5.4.5 for the time being so we aren't subject to the breaking change in 5.5 with the removal of "importsNotUsedAsValues": "error"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cacieprins I wound up going with the above comment in d3916e9

/* skips checking declaration types. we skip this because we have multiple versions of vite installed as dev dependencies */
"skipLibCheck": true,
Expand Down
4 changes: 2 additions & 2 deletions npm/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
"debug": "^4.3.4",
"globby": "^11.0.1",
"tailwindcss": "1.1.4",
"typescript": "^4.7.4",
"typescript": "~5.4.5",
"vite": "4.5.2",
"vue": "3.2.47",
"vue-i18n": "9.0.0-rc.6",
"vue-router": "^4.0.0",
"vue-tsc": "^0.3.0",
"vue-tsc": "^2.0.19",
"vuex": "^4.0.0"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion npm/vue2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@rollup/plugin-replace": "^2.3.1",
"@vue/test-utils": "^1.3.1",
"tslib": "^2.1.0",
"typescript": "^4.7.4",
"typescript": "~5.4.5",
"vue": "2.7.16"
},
"peerDependencies": {
Expand Down
45 changes: 40 additions & 5 deletions npm/webpack-batteries-included-preprocessor/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
const path = require('path')
const fs = require('fs-extra')
const JSON5 = require('json5')
const webpack = require('webpack')
const Debug = require('debug')
const webpackPreprocessor = require('@cypress/webpack-preprocessor')

const debug = Debug('cypress:webpack-batteries-included-preprocessor')

const hasTsLoader = (rules) => {
return rules.some((rule) => {
if (!rule.use || !Array.isArray(rule.use)) return false
Expand All @@ -12,6 +17,38 @@ const hasTsLoader = (rules) => {
})
}

const getTSCompilerOptionsForUser = (configFilePath) => {
const compilerOptions = {
sourceMap: false,
inlineSourceMap: true,
inlineSources: true,
downlevelIteration: true,
}

if (!configFilePath) {
return compilerOptions
}

try {
// If possible, try to read the user's tsconfig.json and see if sourceMap is configured
// eslint-disable-next-line no-restricted-syntax
const tsconfigJSON = fs.readFileSync(configFilePath, 'utf8')
// file might have trailing commas, new lines, etc. JSON5 can parse those correctly
const parsedJSON = JSON5.parse(tsconfigJSON)

// if the user has sourceMap's configured, set the option to true and turn off inlineSourceMaps
if (parsedJSON?.compilerOptions?.sourceMap) {
compilerOptions.sourceMap = true
compilerOptions.inlineSourceMap = false
compilerOptions.inlineSources = false
}
} catch (e) {
debug(`error in getTSCompilerOptionsForUser. Returning default...`, e)
} finally {
return compilerOptions
}
}

const addTypeScriptConfig = (file, options) => {
// shortcut if we know we've already added typescript support
if (options.__typescriptSupportAdded) return options
Expand All @@ -30,6 +67,8 @@ const addTypeScriptConfig = (file, options) => {
// package using require('tsconfig'), so we alias it as 'tsconfig-aliased-for-wbip'
const configFile = require('tsconfig-aliased-for-wbip').findSync(path.dirname(file.filePath))

const compilerOptions = getTSCompilerOptionsForUser(configFile)

webpackOptions.module.rules.push({
test: /\.tsx?$/,
exclude: [/node_modules/],
Expand All @@ -38,11 +77,7 @@ const addTypeScriptConfig = (file, options) => {
loader: require.resolve('ts-loader'),
options: {
compiler: options.typescript,
compilerOptions: {
inlineSourceMap: true,
inlineSources: true,
downlevelIteration: true,
},
compilerOptions,
logLevel: 'error',
silent: true,
transpileOnly: true,
Expand Down
9 changes: 7 additions & 2 deletions npm/webpack-batteries-included-preprocessor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
"coffeescript": "2.6.0",
"constants-browserify": "^1.0.0",
"crypto-browserify": "^3.12.0",
"debug": "^4.3.4",
"domain-browser": "^4.22.0",
"events": "^3.3.0",
"fs-extra": "^9.1.0",
"https-browserify": "^1.0.0",
"json5": "2.2.3",
"os-browserify": "^0.3.0",
"path-browserify": "^1.0.1",
"pnp-webpack-plugin": "^1.7.0",
Expand All @@ -50,10 +53,12 @@
"@types/mocha": "^8.0.2",
"@types/webpack": "^5.28.1",
"chai": "^4.2.0",
"fs-extra": "^9.1.0",
"decache": "^4.6.2",
"mocha": "^8.1.1",
"mock-require": "3.0.3",
"react": "^16.13.1",
"typescript": "^4.7.4"
"sinon": "18.0.0",
"typescript": "^5.4.5"
},
"peerDependencies": {
"@cypress/webpack-preprocessor": "^5.4.4"
Expand Down
Loading
Loading