mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-25 00:19:11 -05:00
chore: update to webpack v5 (#27438)
* chore: [run ci] does further prerequisites for webpack 5: https://webpack.js.org/migrate/5/#make-sure-your-build-has-no-errors-or-warnings https://webpack.js.org/migrate/5/#make-sure-to-use-mode https://webpack.js.org/migrate/5/#update-outdated-options https://webpack.js.org/migrate/5/#test-webpack-5-compatibility app builds and runs locally. Time to test out in CI and see if buffer or process need to be polyfilled by the build * chore: upgrade to webpack 5 and do the bare minimum to get it working * chore: get @packages/extension working * chore: add TODOs to finish after webpack 5 update * chore: update the webpack config for npm/webpack-batteries-included-preprocessor to be webpack 5 compliant * chore: patch whatwg-url 7.1.0. package 'source-map' uses whatwg-url@7.1.0 which has a dependency on punycode node expected API. since punycode is now polyfilled for us implicitly via the punycode npm package, the API signatures are a bit different https://github.com/mathiasbynens/punycode.js/blob/main/punycode.js#L101 vs https://nodejs.org/api/punycode.html#punycodeucs2. The patch uses the punycode npm package expected API and is needed for source maps to work for cy.origin() dependencies for Cypress.require() * chore: convert whatwg patch into dev patch as source-map is not installed when building the binary / installing prod dependencies * chore: only move production level patches into the binary dist directory for yarn install --production * chore: remove --openssl-legacy-provider code for node versions 17 and over as webpack has been updated to v5 * chore: fix the webpack-batteries-included-preprocessor tests by shimming the correct node globals and built ins * chore: provide the define plugin and evalDevtoolPlugin again as we need define in order to build the react-dom library correctly in the bundle to not include the development version * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: fix the webpack preprocessor not to change promise references under the hood when compiling the first bundle, as it was causing the webpack preprocessor to hang as the reference itself was different * chore: fix issues from readFile that were caused by Webpack 5 using 'path-browserify' * chore: update chrome component testing snapshots to match Webpack 5 changes * chore: fix mismatched snapshots from webpack 5 update * chore: use Cypress.Buffer instead of Buffer for selectFile system test to avoid having to polyfill Buffer from webpack * chore: fix system test webpack path that now includes e2e workspace * chore: patch enhanced-resolve to properly discover the pnp api for the yarn_v3.1.1_pnp_spec.ts system test. see https://github.com/webpack/enhanced-resolve/issues/263 for more details * chore: set stats to 'none' for experimentalSingleTabMode to prevent different webpack compiled terminal formatting in the snapshot between local and CI. * chore: fix node built in tests and configure webpack-batteries-included-preprocessor correctly * chore: fallback to buffer correctly in config, even though there is no impact due to the provide plugin * Update binary-cleanup.js to exclude added build dependencies for webpack 5 added by webpack-terser-plugin under the hood * chore: add stream-browserify to webpack preprocessor batteries included as a dep as its used in the config [run ci] * chore: make sure process and buffer are installed in the CLI for webpack provide * chore: build cross platform binaries [run ci] * chore: fix webpack evalDevToolPlugin instantiation [run ci] * run all binary jobs [run ci] * chore: updating v8 snapshot cache * add find-up to the entry points that need to be kept * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: fix mocha build warnings * chore: fix STRIPPED_INTEGRITY_TAG import warnings * chore: add changelog event --------- Co-authored-by: cypress-bot[bot] <+cypress-bot[bot]@users.noreply.github.com> Co-authored-by: Ryan Manuel <ryanm@cypress.io>
This commit is contained in:
@@ -7,6 +7,10 @@ _Released 08/15/2023 (PENDING)_
|
||||
|
||||
- Fixed an issue where having `cypress.config` in a nested directory would cause problems with locating the `component-index.html` file when using component testing. Fixes [#26400](https://github.com/cypress-io/cypress/issues/26400).
|
||||
|
||||
**Dependency Updates:**
|
||||
|
||||
- Upgraded [`webpack`](https://www.npmjs.com/package/webpack) from `v4` to `v5`. This means that we are now bundling your `e2e` tests with webpack 5. We don't anticipate this causing any noticeable changes. However, if you'd like to keep bundling your `e2e` tests with wepback 4 you can use the same process as before by pinning [@cypress/webpack-batteries-included-preprocessor](https://www.npmjs.com/package/@cypress/webpack-batteries-included-preprocessor) to `v2.x.x` and hooking into the [file:preprocessor](https://docs.cypress.io/api/plugins/preprocessors-api#Usage) plugin event. This will restore the previous bundling process. Additionally, if you're using [@cypress/webpack-batteries-included-preprocessor](https://www.npmjs.com/package/@cypress/webpack-batteries-included-preprocessor) already, a new version has been published to support webpack `v5`.
|
||||
|
||||
## 12.17.3
|
||||
|
||||
_Released 08/01/2023_
|
||||
|
||||
@@ -21,7 +21,6 @@ const isInstalledGlobally = require('is-installed-globally')
|
||||
const logger = require('./logger')
|
||||
const debug = require('debug')('cypress:cli')
|
||||
const fs = require('./fs')
|
||||
const semver = require('semver')
|
||||
|
||||
const pkg = require(path.join(__dirname, '..', 'package.json'))
|
||||
|
||||
@@ -305,21 +304,6 @@ const util = {
|
||||
opts.ORIGINAL_NODE_OPTIONS = process.env.NODE_OPTIONS
|
||||
}
|
||||
|
||||
// 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 plugins
|
||||
// process.
|
||||
|
||||
// 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') && semver.satisfies(process.versions.openssl, '>=3', { includePrerelease: true })) {
|
||||
opts.ORIGINAL_NODE_OPTIONS = `${opts.ORIGINAL_NODE_OPTIONS || ''} --openssl-legacy-provider`
|
||||
}
|
||||
|
||||
return opts
|
||||
},
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
"minimist": "^1.2.8",
|
||||
"ospath": "^1.2.2",
|
||||
"pretty-bytes": "^5.6.0",
|
||||
"process": "^0.11.10",
|
||||
"proxy-from-env": "1.0.0",
|
||||
"request-progress": "^3.0.0",
|
||||
"semver": "^7.5.3",
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* as of Webpack 5, dependencies that are polyfilled through the Provide plugin must be defined inside the CLI
|
||||
* in order to guarantee there is a version of the dependency accessible by the cypress CLI, either in the cypress directory
|
||||
* or the root of their project. Currently, these two dependencies are 'buffer' and 'process'
|
||||
*/
|
||||
describe('dependencies', () => {
|
||||
it('process dependency exists in package.json and is available', () => {
|
||||
const { dependencies } = require('../../../package.json')
|
||||
|
||||
expect(dependencies.process).to.be.ok
|
||||
|
||||
const process = require('process')
|
||||
|
||||
expect(typeof process).to.equal('object')
|
||||
})
|
||||
|
||||
it('buffer dependency exists in package.json and is available', () => {
|
||||
const { dependencies } = require('../../../package.json')
|
||||
|
||||
expect(dependencies.buffer).to.be.ok
|
||||
|
||||
const buffer = require('buffer')
|
||||
|
||||
expect(typeof buffer).to.equal('object')
|
||||
})
|
||||
})
|
||||
@@ -278,68 +278,6 @@ describe('util', () => {
|
||||
ORIGINAL_NODE_OPTIONS: '--require foo.js',
|
||||
})
|
||||
})
|
||||
|
||||
// https://github.com/cypress-io/cypress/issues/18914
|
||||
it('includes --openssl-legacy-provider in Node 17+ w/ OpenSSL 3', () => {
|
||||
sandbox.stub(process.versions, 'node').value('v17.1.0')
|
||||
sandbox.stub(process.versions, 'openssl').value('3.0.0-quic')
|
||||
|
||||
restoreEnv = mockedEnv({
|
||||
NODE_OPTIONS: '--require foo.js',
|
||||
})
|
||||
|
||||
let childOptions = util.getOriginalNodeOptions()
|
||||
|
||||
expect(childOptions.ORIGINAL_NODE_OPTIONS).to.eq('--require foo.js --openssl-legacy-provider')
|
||||
|
||||
restoreEnv()
|
||||
restoreEnv = mockedEnv({})
|
||||
childOptions = util.getOriginalNodeOptions()
|
||||
|
||||
expect(childOptions.ORIGINAL_NODE_OPTIONS).to.eq(' --openssl-legacy-provider')
|
||||
})
|
||||
|
||||
// https://github.com/cypress-io/cypress/issues/19320
|
||||
it('does not include --openssl-legacy-provider in Node 17+ w/ OpenSSL 1', () => {
|
||||
sandbox.stub(process.versions, 'node').value('v17.1.0')
|
||||
sandbox.stub(process.versions, 'openssl').value('1.0.0')
|
||||
|
||||
restoreEnv = mockedEnv({
|
||||
NODE_OPTIONS: '--require foo.js',
|
||||
})
|
||||
|
||||
let childOptions = util.getOriginalNodeOptions()
|
||||
|
||||
expect(childOptions.ORIGINAL_NODE_OPTIONS).to.eq('--require foo.js')
|
||||
expect(childOptions.ORIGINAL_NODE_OPTIONS).not.to.contain('--openssl-legacy-provider')
|
||||
|
||||
restoreEnv()
|
||||
restoreEnv = mockedEnv({})
|
||||
childOptions = util.getOriginalNodeOptions()
|
||||
|
||||
expect(childOptions.ORIGINAL_NODE_OPTIONS).to.be.undefined
|
||||
})
|
||||
|
||||
// https://github.com/cypress-io/cypress/issues/18914
|
||||
it('does not include --openssl-legacy-provider in Node <=16', () => {
|
||||
sandbox.stub(process.versions, 'node').value('v16.14.2')
|
||||
sandbox.stub(process.versions, 'openssl').value('1.0.0')
|
||||
|
||||
restoreEnv = mockedEnv({})
|
||||
|
||||
let childOptions = util.getOriginalNodeOptions()
|
||||
|
||||
expect(childOptions.ORIGINAL_NODE_OPTIONS).to.be.undefined
|
||||
|
||||
restoreEnv = mockedEnv({
|
||||
NODE_OPTIONS: '--require foo.js',
|
||||
})
|
||||
|
||||
childOptions = util.getOriginalNodeOptions()
|
||||
|
||||
expect(childOptions.ORIGINAL_NODE_OPTIONS).to.eq('--require foo.js')
|
||||
expect(childOptions.ORIGINAL_NODE_OPTIONS).not.to.contain('--openssl-legacy-provider')
|
||||
})
|
||||
})
|
||||
|
||||
context('.exit', () => {
|
||||
|
||||
Reference in New Issue
Block a user