diff --git a/cli/lib/util.js b/cli/lib/util.js index 0473af32ba1a..e6d02fe65dba 100644 --- a/cli/lib/util.js +++ b/cli/lib/util.js @@ -315,7 +315,7 @@ const util = { // To be removed when the Cypress binary pulls in the @cypress/webpack-batteries-included-preprocessor // version that has been updated to webpack >= 5.61, which no longer relies on // Node's builtin crypto.hash function. - if (process.versions && semver.satisfies(process.versions.node, '>=17.0.0') && process.versions.openssl.startsWith('3.')) { + if (process.versions && semver.satisfies(process.versions.node, '>=17.0.0') && semver.satisfies(process.versions.openssl, '>=3', { includePrerelease: true })) { opts.ORIGINAL_NODE_OPTIONS = `${opts.ORIGINAL_NODE_OPTIONS || ''} --openssl-legacy-provider` } diff --git a/npm/webpack-dev-server/src/createWebpackDevServer.ts b/npm/webpack-dev-server/src/createWebpackDevServer.ts index 8ab9f9fce321..4b3cd14d999e 100644 --- a/npm/webpack-dev-server/src/createWebpackDevServer.ts +++ b/npm/webpack-dev-server/src/createWebpackDevServer.ts @@ -68,7 +68,7 @@ function webpackDevServer4 ( const { devServerConfig: { cypressConfig: { devServerPublicPathRoute } } } = config const WebpackDevServer = config.sourceWebpackModulesResult.webpackDevServer.module const webpackDevServerConfig = { - host: 'localhost', + host: '127.0.0.1', port: 'auto', // @ts-ignore ...finalWebpackConfig?.devServer, diff --git a/npm/webpack-dev-server/test/devServer-e2e.spec.ts b/npm/webpack-dev-server/test/devServer-e2e.spec.ts index cce81792fe4e..88419e56da73 100644 --- a/npm/webpack-dev-server/test/devServer-e2e.spec.ts +++ b/npm/webpack-dev-server/test/devServer-e2e.spec.ts @@ -12,7 +12,7 @@ import './support' const requestSpecFile = (file: string, port: number) => { return new Promise((res) => { const opts = { - host: 'localhost', + host: '127.0.0.1', port, path: encodeURI(file), } diff --git a/packages/extension/gulpfile.ts b/packages/extension/gulpfile.ts index e5f29b75e29a..b171ba308361 100644 --- a/packages/extension/gulpfile.ts +++ b/packages/extension/gulpfile.ts @@ -1,8 +1,9 @@ import gulp from 'gulp' import rimraf from 'rimraf' -import webpack from 'webpack' import * as cypressIcons from '@packages/icons' -import webpackConfig from './webpack.config.js' +import cp from 'child_process' +import util from 'util' +const exec = util.promisify(cp.exec) const clean = (done) => { rimraf('dist', done) @@ -14,9 +15,7 @@ const manifest = () => { } const background = (cb) => { - const compiler = webpack(webpackConfig as webpack.Configuration) - - compiler.run(cb) + exec('node ../../scripts/run-webpack.js').then(() => cb()).catch(cb) } const html = () => { diff --git a/packages/extension/package.json b/packages/extension/package.json index 4870363630bd..9d98d57a5ec0 100644 --- a/packages/extension/package.json +++ b/packages/extension/package.json @@ -13,7 +13,7 @@ "test-debug": "yarn test-unit --inspect-brk=5566", "test-unit": "cross-env NODE_ENV=test mocha -r @packages/ts/register --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json", "test-watch": "yarn test-unit --watch", - "watch": "webpack --watch --progress" + "watch": "node ../../scripts/run-webpack --watch --progress" }, "dependencies": { "bluebird": "3.5.3", diff --git a/packages/reporter/package.json b/packages/reporter/package.json index c71721656797..f6bfe9374590 100644 --- a/packages/reporter/package.json +++ b/packages/reporter/package.json @@ -4,7 +4,7 @@ "private": true, "browser": "src/main.tsx", "scripts": { - "build-for-tests": "webpack", + "build-for-tests": "node ../../scripts/run-webpack", "clean-deps": "rimraf node_modules", "cypress:open": "node ../../scripts/cypress open --project .", "cypress:run": "node ../../scripts/cypress run --project .", diff --git a/packages/runner-ct/package.json b/packages/runner-ct/package.json index d9c5c4030e92..70bfa8c43729 100644 --- a/packages/runner-ct/package.json +++ b/packages/runner-ct/package.json @@ -4,7 +4,7 @@ "private": true, "browser": "src/index.js", "scripts": { - "build": "webpack", + "build": "node ../../scripts/run-webpack", "build-prod": "cross-env NODE_ENV=production yarn build && tsc", "clean-deps": "rimraf node_modules", "cypress:open": "ts-node ../../scripts/cypress.js open --component --project .", @@ -12,7 +12,7 @@ "postinstall": "echo '@packages/runner needs: yarn build'", "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json src", "test": "ts-node ../../scripts/cypress.js run --component --project .", - "watch": "webpack --watch --progress --config webpack.config.ts" + "watch": "node ../../scripts/run-webpack --watch --progress --config webpack.config.ts" }, "dependencies": {}, "devDependencies": { diff --git a/packages/runner/package.json b/packages/runner/package.json index 22ea23da0740..54843b961d70 100644 --- a/packages/runner/package.json +++ b/packages/runner/package.json @@ -4,7 +4,7 @@ "private": true, "browser": "src/index.js", "scripts": { - "build": "webpack", + "build": "node ../../scripts/run-webpack", "build-prod": "cross-env NODE_ENV=production yarn build", "clean-deps": "rimraf node_modules", "cypress:open": "node ../../scripts/cypress open", @@ -14,7 +14,7 @@ "test-debug": "yarn test-unit --inspect-brk=5566", "test-unit": "mocha --config test/.mocharc.json src/**/*.spec.* --exit", "test-watch": "yarn test-unit --watch", - "watch": "webpack --watch --progress" + "watch": "node ../../scripts/run-webpack --watch --progress" }, "devDependencies": { "@cypress/react-tooltip": "0.5.3", diff --git a/packages/ui-components/package.json b/packages/ui-components/package.json index e8a24c692f2b..ffe834019dfb 100644 --- a/packages/ui-components/package.json +++ b/packages/ui-components/package.json @@ -4,7 +4,7 @@ "private": true, "main": "src/index.tsx", "scripts": { - "build-for-tests": "webpack", + "build-for-tests": "node ../../scripts/run-webpack", "check-deps": "node ../../scripts/check-deps.js --verbose", "check-deps-pre": "npm run check-deps -- --prescript", "clean-deps": "rimraf node_modules", @@ -39,6 +39,6 @@ "react-dom": "16.8.6", "rimraf": "3.0.2", "webpack": "^4.44.2", - "webpack-cli": "3.3.11" + "webpack-cli": "3.3.2" } } diff --git a/packages/web-config/package.json b/packages/web-config/package.json index cdcaeb81b0fe..f94449c9dc47 100644 --- a/packages/web-config/package.json +++ b/packages/web-config/package.json @@ -39,7 +39,7 @@ "sass-loader": "10.1.0", "sinon-chai": "3.3.0", "webpack": "^4.44.2", - "webpack-cli": "3.3.11", + "webpack-cli": "3.3.2", "webpack-livereload-plugin": "2.3.0" } } diff --git a/scripts/gulp/tasks/gulpWebpack.ts b/scripts/gulp/tasks/gulpWebpack.ts index 56b069cdb5fa..44e1d3df89d2 100644 --- a/scripts/gulp/tasks/gulpWebpack.ts +++ b/scripts/gulp/tasks/gulpWebpack.ts @@ -3,6 +3,9 @@ import pDefer from 'p-defer' import { monorepoPaths } from '../monorepoPaths' import { universalSpawn } from '../utils/childProcessUtils' import { addChildProcess } from './gulpRegistry' +import semver from 'semver' + +type Env = typeof process.env export function webpackRunner () { return runWebpack({ @@ -16,10 +19,27 @@ type RunWebpackCfg = { cwd: string prefix: string args?: string[] - env?: object + env?: Env devServer?: boolean } +// https://github.com/cypress-io/cypress/issues/18914 +// Node 17+ ships with OpenSSL 3 by default, so we may need the option +// --openssl-legacy-provider so that webpack@4 can use the legacy MD4 hash +// function. This option doesn't exist on Node <17 or when it is built +// against OpenSSL 1, so we have to detect Node's major version and check +// which version of OpenSSL it was built against before spawning the process. +// +// Can be removed once the webpack version is upgraded to >= 5.61, +// which no longer relies on Node's builtin crypto.hash function. +function useLegacyOpenSSLProvider (env: Env) { + if (process.versions && semver.satisfies(process.versions.node, '>=17.0.0') && semver.satisfies(process.versions.openssl, '>=3', { includePrerelease: true })) { + return { NODE_OPTIONS: `${env.NODE_OPTIONS ?? ''} --openssl-legacy-provider` } + } + + return {} +} + export async function runWebpack (cfg: RunWebpackCfg) { const { cwd, args = [], env = process.env, devServer = false, prefix } = cfg const dfd = pDefer() @@ -32,6 +52,7 @@ export async function runWebpack (cfg: RunWebpackCfg) { cwd, env: { ...(env || process.env), + ...useLegacyOpenSSLProvider(env), FORCE_COLOR: '1', }, }, diff --git a/scripts/run-webpack.js b/scripts/run-webpack.js new file mode 100644 index 000000000000..150aca60edd7 --- /dev/null +++ b/scripts/run-webpack.js @@ -0,0 +1,23 @@ +const cp = require('child_process') +const path = require('path') +const semver = require('semver') + +const webpackCli = path.join(__dirname, '..', 'node_modules', 'webpack-cli', 'bin', 'cli.js') + +// https://github.com/cypress-io/cypress/issues/18914 +// Node 17+ ships with OpenSSL 3 by default, so we may need the option +// --openssl-legacy-provider so that webpack@4 can use the legacy MD4 hash +// function. This option doesn't exist on Node <17 or when it is built +// against OpenSSL 1, so we have to detect Node's major version and check +// which version of OpenSSL it was built against before spawning the process. +// +// Can be removed once the webpack version is upgraded to >= 5.61, +// which no longer relies on Node's builtin crypto.hash function. + +let NODE_OPTIONS = process.env.NODE_OPTIONS || '' + +if (process.versions && semver.satisfies(process.versions.node, '>=17.0.0') && semver.satisfies(process.versions.openssl, '>=3', { includePrerelease: true })) { + NODE_OPTIONS = `${NODE_OPTIONS} --openssl-legacy-provider` +} + +cp.execSync(`node ${webpackCli} ${process.argv.slice(2).join(' ')}`, { stdio: 'inherit', env: { ...process.env, NODE_OPTIONS } }) diff --git a/system-tests/lib/system-tests.ts b/system-tests/lib/system-tests.ts index 8ef5a0b5867e..8fcea1edf6bf 100644 --- a/system-tests/lib/system-tests.ts +++ b/system-tests/lib/system-tests.ts @@ -818,6 +818,7 @@ const systemTests = { const args = options.withBinary ? [ `run`, `--project=${projectPath}`, + options.testingType === 'component' ? '--component' : '--e2e', ] : [ require.resolve('@packages/server'), // hides a user warning to go through NPM module diff --git a/system-tests/test-binary/node_versions_spec.ts b/system-tests/test-binary/node_versions_spec.ts index 8d1483ab410c..c3f5a4e37db5 100644 --- a/system-tests/test-binary/node_versions_spec.ts +++ b/system-tests/test-binary/node_versions_spec.ts @@ -1,17 +1,30 @@ import systemTests from '../lib/system-tests' function smokeTestDockerImage (dockerImage: string) { - systemTests.it(`can run in ${dockerImage}`, { - withBinary: true, - browser: 'electron', - dockerImage, - spec: 'test1.js', - specDir: 'tests', - project: 'todos', + context('e2e', () => { + systemTests.it(`can run in ${dockerImage}`, { + withBinary: true, + browser: 'electron', + dockerImage, + spec: 'test1.js', + specDir: 'tests', + project: 'todos', + }) + }) + + context('component', () => { + systemTests.it(`can run in ${dockerImage}`, { + withBinary: true, + browser: 'electron', + dockerImage, + testingType: 'component', + project: 'simple-ct', + spec: 'src/simple_passing_component.cy.js', + }) }) } -describe('e2e binary node versions', () => { +describe('binary node versions', () => { [ 'cypress/base:12', 'cypress/base:14', diff --git a/yarn.lock b/yarn.lock index 86710b99b3d4..eec5e315052a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16440,15 +16440,6 @@ engine.io@~5.0.0: engine.io-parser "~4.0.0" ws "~7.4.2" -enhanced-resolve@4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-4.1.0.tgz#41c7e0bfdfe74ac1ffe1e57ad6a5c6c9f3742a7f" - integrity sha512-F/7vkyTtyc/llOIn8oWclcB25KdRaiPBpZYDgJHgh/UHtpgT2p2eldQgtQnLtUvfMKPKxbRaQM/hHkvLHt1Vng== - dependencies: - graceful-fs "^4.1.2" - memory-fs "^0.4.0" - tapable "^1.0.0" - enhanced-resolve@5.7.0: version "5.7.0" resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.7.0.tgz#525c5d856680fbd5052de453ac83e32049958b5c" @@ -18517,16 +18508,6 @@ find-yarn-workspace-root@^2.0.0: dependencies: micromatch "^4.0.2" -findup-sync@3.0.0, findup-sync@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-3.0.0.tgz#17b108f9ee512dfb7a5c7f3c8b27ea9e1a9c08d1" - integrity sha512-YbffarhcicEhOrm4CtrwdKBdCuz576RLdhJDsIfvNtxUuhdRet1qZcsMjqbePtAseKdAnDyM/IyXbu7PRPRLYg== - dependencies: - detect-file "^1.0.0" - is-glob "^4.0.0" - micromatch "^3.0.4" - resolve-dir "^1.0.1" - findup-sync@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-2.0.0.tgz#9326b1488c22d1a6088650a86901b2d9a90a2cbc" @@ -18537,6 +18518,16 @@ findup-sync@^2.0.0: micromatch "^3.0.4" resolve-dir "^1.0.1" +findup-sync@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-3.0.0.tgz#17b108f9ee512dfb7a5c7f3c8b27ea9e1a9c08d1" + integrity sha512-YbffarhcicEhOrm4CtrwdKBdCuz576RLdhJDsIfvNtxUuhdRet1qZcsMjqbePtAseKdAnDyM/IyXbu7PRPRLYg== + dependencies: + detect-file "^1.0.0" + is-glob "^4.0.0" + micromatch "^3.0.4" + resolve-dir "^1.0.1" + fined@^1.0.1: version "1.2.0" resolved "https://registry.yarnpkg.com/fined/-/fined-1.2.0.tgz#d00beccf1aa2b475d16d423b0238b713a2c4a37b" @@ -21106,7 +21097,7 @@ import-lazy@^2.1.0: resolved "https://registry.yarnpkg.com/import-lazy/-/import-lazy-2.1.0.tgz#05698e3d45c88e8d7e9d92cb0584e77f096f3e43" integrity sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM= -import-local@2.0.0, import-local@^2.0.0: +import-local@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/import-local/-/import-local-2.0.0.tgz#55070be38a5993cf18ef6db7e961f5bee5c5a09d" integrity sha512-b6s04m3O+s3CGSbqDIyP4R6aAwAeYlVq9+WUWep6iHa8ETRf9yei1U48C5MmfJmV9AiLYYBKPMq/W+/WRpQmCQ== @@ -21371,11 +21362,6 @@ internal-slot@^1.0.3: has "^1.0.3" side-channel "^1.0.4" -interpret@1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.2.0.tgz#d5061a6224be58e8083985f5014d844359576296" - integrity sha512-mT34yGKMNceBQUoVn7iCDKDntA7SC6gycMAWzGx1z/CMCTV7b2AAtXlo3nRyHZ1FelRkQbQjprHSYGwzLtkVbw== - interpret@^1.0.0, interpret@^1.1.0, interpret@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.4.0.tgz#665ab8bc4da27a774a40584e812e3e0fa45b1a1e" @@ -25348,7 +25334,7 @@ memfs@^3.4.1: dependencies: fs-monkey "1.0.3" -memory-fs@^0.4.0, memory-fs@^0.4.1: +memory-fs@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.4.1.tgz#3a9a20b8462523e447cfbc7e8bb80ed667bfc552" integrity sha1-OpoguEYlI+RHz7x+i7gO1me/xVI= @@ -35087,13 +35073,6 @@ supports-color@6.0.0: dependencies: has-flag "^3.0.0" -supports-color@6.1.0, supports-color@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.1.0.tgz#0764abc69c63d5ac842dd4867e8d025e880df8f3" - integrity sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ== - dependencies: - has-flag "^3.0.0" - supports-color@8.1.1, supports-color@^8.0.0, supports-color@^8.1.0, supports-color@^8.1.1: version "8.1.1" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" @@ -35113,6 +35092,13 @@ supports-color@^5.3.0, supports-color@^5.4.0, supports-color@^5.5.0: dependencies: has-flag "^3.0.0" +supports-color@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.1.0.tgz#0764abc69c63d5ac842dd4867e8d025e880df8f3" + integrity sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ== + dependencies: + has-flag "^3.0.0" + supports-color@^7.0.0, supports-color@^7.1.0, supports-color@^7.2.0: version "7.2.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" @@ -37066,7 +37052,7 @@ v8-compile-cache-lib@^3.0.0: resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz#0582bcb1c74f3a2ee46487ceecf372e46bce53e8" integrity sha512-mpSYqfsFvASnSn5qMiwrr4VKfumbPyONLCOPmsR3A6pTY/r0+tSaVbgPWSAIuzbk3lCTa+FForeTiO+wBQGkjA== -v8-compile-cache@2.0.3, v8-compile-cache@^2.0.2, v8-compile-cache@^2.0.3: +v8-compile-cache@^2.0.2, v8-compile-cache@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.0.3.tgz#00f7494d2ae2b688cfe2899df6ed2c54bef91dbe" integrity sha512-CNmdbwQMBjwr9Gsmohvm0pbL954tJrNzf6gWL3K+QMQf00PF7ERGrEiLgjuU3mKreLC2MeGhUsNV9ybTbLgd3w== @@ -37751,23 +37737,6 @@ webidl-conversions@^4.0.2: watchpack "^1.7.4" webpack-sources "^1.4.1" -webpack-cli@3.3.11: - version "3.3.11" - resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-3.3.11.tgz#3bf21889bf597b5d82c38f215135a411edfdc631" - integrity sha512-dXlfuml7xvAFwYUPsrtQAA9e4DOe58gnzSxhgrO/ZM/gyXTBowrsYeubyN4mqGhYdpXMFNyQ6emjJS9M7OBd4g== - dependencies: - chalk "2.4.2" - cross-spawn "6.0.5" - enhanced-resolve "4.1.0" - findup-sync "3.0.0" - global-modules "2.0.0" - import-local "2.0.0" - interpret "1.2.0" - loader-utils "1.2.3" - supports-color "6.1.0" - v8-compile-cache "2.0.3" - yargs "13.2.4" - webpack-cli@3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-3.3.2.tgz#aed2437b0db0a7faa2ad28484e166a5360014a91" @@ -38982,7 +38951,7 @@ yargs-parser@13.1.1: camelcase "^5.0.0" decamelize "^1.2.0" -yargs-parser@13.1.2, yargs-parser@^13.1.0, yargs-parser@^13.1.1, yargs-parser@^13.1.2: +yargs-parser@13.1.2, yargs-parser@^13.1.1, yargs-parser@^13.1.2: version "13.1.2" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.2.tgz#130f09702ebaeef2650d54ce6e3e5706f7a4fb38" integrity sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg== @@ -39097,23 +39066,6 @@ yargs@12.0.2: y18n "^3.2.1 || ^4.0.0" yargs-parser "^10.1.0" -yargs@13.2.4: - version "13.2.4" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.2.4.tgz#0b562b794016eb9651b98bd37acf364aa5d6dc83" - integrity sha512-HG/DWAJa1PAnHT9JAhNa8AbAv3FPaiLzioSjCcmuXXhP8MlpHO5vwls4g4j6n30Z74GVQj8Xa62dWVx1QCGklg== - dependencies: - cliui "^5.0.0" - find-up "^3.0.0" - get-caller-file "^2.0.1" - os-locale "^3.1.0" - require-directory "^2.1.1" - require-main-filename "^2.0.0" - set-blocking "^2.0.0" - string-width "^3.0.0" - which-module "^2.0.0" - y18n "^4.0.0" - yargs-parser "^13.1.0" - yargs@13.3.0: version "13.3.0" resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.3.0.tgz#4c657a55e07e5f2cf947f8a366567c04a0dedc83"