Skip to content

Commit 2fd8712

Browse files
authored
breaking: the minimum version of webpack for webpack-preprocessor and webpack-batteries-included-preprocessor is webpack 5. both packages need a breaking version published (check the peerDeps in WBIP)" (#31506)
breaking: webpack/wds v4 is no longer supported in @cypress/webpack-dev-server update changelog and clean up comments
1 parent d00809c commit 2fd8712

File tree

36 files changed

+207
-10869
lines changed

36 files changed

+207
-10869
lines changed

.circleci/cache-version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Bump this version to force CI to re-create the cache from scratch.
22

3-
4-24-2025
3+
4-28-2025

.circleci/workflows.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ mainBuildFilters: &mainBuildFilters
3838
- /^release\/\d+\.\d+\.\d+$/
3939
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
4040
- 'update-v8-snapshot-cache-on-develop'
41-
- 'feat/replace_tsnode_for_tsx_config_process'
41+
- 'breaking/remove_webpack_4'
4242

4343
# usually we don't build Mac app - it takes a long time
4444
# but sometimes we want to really confirm we are doing the right thing
@@ -49,7 +49,7 @@ macWorkflowFilters: &darwin-workflow-filters
4949
- equal: [ develop, << pipeline.git.branch >> ]
5050
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
5151
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
52-
- equal: [ 'feat/replace_tsnode_for_tsx_config_process', << pipeline.git.branch >> ]
52+
- equal: [ 'breaking/remove_webpack_4', << pipeline.git.branch >> ]
5353
- matches:
5454
pattern: /^release\/\d+\.\d+\.\d+$/
5555
value: << pipeline.git.branch >>
@@ -60,7 +60,7 @@ linuxArm64WorkflowFilters: &linux-arm64-workflow-filters
6060
- equal: [ develop, << pipeline.git.branch >> ]
6161
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
6262
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
63-
- equal: [ 'feat/replace_tsnode_for_tsx_config_process', << pipeline.git.branch >> ]
63+
- equal: [ 'breaking/remove_webpack_4', << pipeline.git.branch >> ]
6464
- matches:
6565
pattern: /^release\/\d+\.\d+\.\d+$/
6666
value: << pipeline.git.branch >>
@@ -83,7 +83,7 @@ windowsWorkflowFilters: &windows-workflow-filters
8383
- equal: [ develop, << pipeline.git.branch >> ]
8484
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
8585
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
86-
- equal: [ 'feat/replace_tsnode_for_tsx_config_process', << pipeline.git.branch >> ]
86+
- equal: [ 'breaking/remove_webpack_4', << pipeline.git.branch >> ]
8787
- matches:
8888
pattern: /^release\/\d+\.\d+\.\d+$/
8989
value: << pipeline.git.branch >>
@@ -157,7 +157,7 @@ commands:
157157
name: Set environment variable to determine whether or not to persist artifacts
158158
command: |
159159
echo "Setting SHOULD_PERSIST_ARTIFACTS variable"
160-
echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "feat/replace_tsnode_for_tsx_config_process" ]]; then
160+
echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "breaking/remove_webpack_4" ]]; then
161161
export SHOULD_PERSIST_ARTIFACTS=true
162162
fi' >> "$BASH_ENV"
163163
# You must run `setup_should_persist_artifacts` command and be using bash before running this command

cli/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ _Released 07/01/2025 (PENDING)_
99
- Removed support for Node.js 18 and Node.js 23. Addresses [#31302](https://github.com/cypress-io/cypress/issues/31302).
1010
- Removed support for [Chrome DevTools Protocol](https://chromedevtools.github.io/devtools-protocol) with the [firefox](https://www.mozilla.org/) browser. Addresses [#31189](https://github.com/cypress-io/cypress/issues/31189).
1111
- The Cypress configuration wizard for Component Testing supports TypeScript 5.0 or greater. Addresses [#31187](https://github.com/cypress-io/cypress/issues/31187).
12+
- `@cypress/webpack-dev-server` and `@cypress/webpack-preprocessor` no longer support `webpack` version 4. Addresses [#31344](https://github.com/cypress-io/cypress/issues/31344). If you still need to use `webpack` version 4, please see our [migration guide](https://docs.cypress.io/app/references/migration-guide#Migrating-to-Cypress-150).
13+
- `@cypress/webpack-dev-server` no longer supports `webpack-dev-server` version 4. Addresses [#31605](https://github.com/cypress-io/cypress/issues/31605). If you still need to use `webpack-dev-server` version 4, please see our [migration guide](https://docs.cypress.io/app/references/migration-guide#Migrating-to-Cypress-150).
1214

1315
**Features:**
1416

npm/webpack-batteries-included-preprocessor/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This preprocessor is a wrapper for [@cypress/webpack-preprocessor](https://githu
1414

1515
Note that installing [@cypress/webpack-preprocessor](https://github.com/cypress-io/cypress-webpack-preprocessor) is also required. This allows you to update its version separately from this wrapper.
1616

17-
For webpack `v5`, use `@cypress/[email protected]`. For webpack `v4`, use `@cypress/[email protected]`.
17+
For webpack `v5`, use `@cypress/[email protected]` and up. For webpack `v4`, use `@cypress/[email protected]`.
1818

1919
```sh
2020
npm install --save-dev @cypress/webpack-batteries-included-preprocessor @cypress/webpack-preprocessor

npm/webpack-batteries-included-preprocessor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"typescript": "~5.4.5"
6060
},
6161
"peerDependencies": {
62-
"@cypress/webpack-preprocessor": "^5.4.4"
62+
"@cypress/webpack-preprocessor": "^6.0.4"
6363
},
6464
"files": [
6565
"index.js",

npm/webpack-dev-server/__snapshots__/makeWebpackConfig.spec.ts.js

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,3 @@
1-
exports['makeWebpackConfig ignores userland webpack `output.publicPath` and `devServer.overlay` with webpack-dev-server v4 1'] = {
2-
'output': {
3-
'publicPath': '/test-public-path/',
4-
'filename': '[name].js',
5-
},
6-
'devServer': {
7-
'client': {
8-
'progress': false,
9-
'overlay': false,
10-
},
11-
},
12-
'optimization': {
13-
'emitOnErrors': true,
14-
'sideEffects': false,
15-
'splitChunks': {
16-
'chunks': 'all',
17-
},
18-
},
19-
'devtool': 'inline-source-map',
20-
'mode': 'development',
21-
'plugins': [
22-
'HtmlWebpackPlugin',
23-
'CypressCTWebpackPlugin',
24-
],
25-
}
26-
271
exports['makeWebpackConfig ignores userland webpack `output.publicPath` and `devServer.overlay` with webpack-dev-server v5 1'] = {
282
'output': {
293
'publicPath': '/test-public-path/',

npm/webpack-dev-server/cypress/e2e/react.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import dedent from 'dedent'
44

55
type ProjectDirs = typeof fixtureDirs
66

7-
const WEBPACK_REACT: ProjectDirs[number][] = ['webpack4_wds4-react', 'webpack5_wds4-react', 'webpack5_wds5-react']
7+
const WEBPACK_REACT: ProjectDirs[number][] = ['webpack5_wds5-react']
88

99
// Add to this list to focus on a particular permutation
1010
const ONLY_PROJECTS: ProjectDirs[number][] = []

npm/webpack-dev-server/cypress/e2e/webpack-dev-server.cy.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
describe('Config options', () => {
44
it('supports supportFile = false', () => {
5-
cy.scaffoldProject('webpack5_wds4-react')
6-
cy.openProject('webpack5_wds4-react', ['--config-file', 'cypress-webpack-no-support.config.ts', '--component'])
5+
cy.scaffoldProject('webpack5_wds5-react')
6+
cy.openProject('webpack5_wds5-react', ['--config-file', 'cypress-webpack-no-support.config.ts', '--component'])
77
cy.startAppServer('component')
88

99
cy.visitApp()
@@ -26,8 +26,8 @@ describe('Config options', () => {
2626
})
2727

2828
it('supports @cypress/webpack-dev-server', () => {
29-
cy.scaffoldProject('webpack5_wds4-react')
30-
cy.openProject('webpack5_wds4-react', ['--config-file', 'cypress-webpack-dev-server-function.config.ts', '--component'])
29+
cy.scaffoldProject('webpack5_wds5-react')
30+
cy.openProject('webpack5_wds5-react', ['--config-file', 'cypress-webpack-dev-server-function.config.ts', '--component'])
3131
cy.startAppServer('component')
3232

3333
cy.visitApp()
@@ -38,8 +38,8 @@ describe('Config options', () => {
3838
})
3939

4040
it('supports webpackConfig as an async function', () => {
41-
cy.scaffoldProject('webpack5_wds4-react')
42-
cy.openProject('webpack5_wds4-react', ['--config-file', 'cypress-webpack-dev-server-async-config.config.ts', '--component'])
41+
cy.scaffoldProject('webpack5_wds5-react')
42+
cy.openProject('webpack5_wds5-react', ['--config-file', 'cypress-webpack-dev-server-async-config.config.ts', '--component'])
4343
cy.startAppServer('component')
4444

4545
cy.visitApp()
@@ -56,8 +56,8 @@ describe('Config options', () => {
5656
})
5757

5858
it('recompiles with new spec and custom indexHtmlFile', () => {
59-
cy.scaffoldProject('webpack5_wds4-react')
60-
cy.openProject('webpack5_wds4-react', ['--config-file', 'cypress-webpack-dev-server-custom-index.config.ts', '--component'])
59+
cy.scaffoldProject('webpack5_wds5-react')
60+
cy.openProject('webpack5_wds5-react', ['--config-file', 'cypress-webpack-dev-server-custom-index.config.ts', '--component'])
6161
cy.startAppServer('component')
6262

6363
cy.visitApp()

npm/webpack-dev-server/package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"dependencies": {
2020
"find-up": "6.3.0",
2121
"fs-extra": "9.1.0",
22-
"html-webpack-plugin-4": "npm:html-webpack-plugin@^4",
2322
"html-webpack-plugin-5": "npm:html-webpack-plugin@^5",
2423
"local-pkg": "0.4.1",
2524
"semver": "^7.7.1",
@@ -39,12 +38,10 @@
3938
"sinon": "^13.0.1",
4039
"snap-shot-it": "^7.9.10",
4140
"ts-node": "^10.9.2",
42-
"webpack": "npm:webpack@^5",
43-
"webpack-4": "npm:webpack@^4",
44-
"webpack-dev-server-4": "npm:webpack-dev-server@^4"
41+
"webpack": "npm:webpack@^5"
4542
},
4643
"peerDependencies": {
47-
"cypress": ">=14.0.0"
44+
"cypress": ">=15.0.0"
4845
},
4946
"files": [
5047
"dist"

npm/webpack-dev-server/src/createWebpackDevServer.ts

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import debugLib from 'debug'
22
import type { Configuration as WebpackDevServer5Configuration } from 'webpack-dev-server'
3-
import type { Configuration as WebpackDevServer4Configuration } from 'webpack-dev-server-4'
43
import type { WebpackDevServerConfig } from './devServer'
54
import type { SourceRelativeWebpackResult } from './helpers/sourceRelativeWebpackModules'
65
import { makeWebpackConfig } from './makeWebpackConfig'
@@ -51,12 +50,6 @@ export async function createWebpackDevServer (
5150
return webpackDevServer5(config, webpackCompiler, finalWebpackConfig)
5251
}
5352

54-
if (webpackDevServerMajorVersion === 4) {
55-
debug('using webpack-dev-server v4')
56-
57-
return webpackDevServer4(config, webpackCompiler, finalWebpackConfig)
58-
}
59-
6053
throw new Error(`Unsupported webpackDevServer version ${webpackDevServerMajorVersion}`)
6154
}
6255

@@ -94,33 +87,3 @@ function webpackDevServer5 (
9487
compiler,
9588
}
9689
}
97-
98-
function webpackDevServer4 (
99-
config: CreateFinalWebpackConfig,
100-
compiler: object,
101-
finalWebpackConfig: Record<string, any>,
102-
) {
103-
const { devServerConfig: { cypressConfig: { devServerPublicPathRoute } } } = config
104-
const isOpenMode = !config.devServerConfig.cypressConfig.isTextTerminal
105-
const WebpackDevServer = config.sourceWebpackModulesResult.webpackDevServer.module
106-
const webpackDevServerConfig: WebpackDevServer4Configuration = {
107-
host: '127.0.0.1',
108-
port: 'auto',
109-
// @ts-ignore
110-
...finalWebpackConfig?.devServer,
111-
devMiddleware: {
112-
publicPath: devServerPublicPathRoute,
113-
stats: finalWebpackConfig.stats ?? 'minimal',
114-
},
115-
hot: false,
116-
// Only enable file watching & reload when executing tests in `open` mode
117-
liveReload: isOpenMode,
118-
}
119-
120-
const server = new WebpackDevServer(webpackDevServerConfig, compiler)
121-
122-
return {
123-
server,
124-
compiler,
125-
}
126-
}

npm/webpack-dev-server/src/devServer.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/// <reference types="cypress" />
22

33
import type WebpackDevServer5 from 'webpack-dev-server'
4-
import type WebpackDevServer4 from 'webpack-dev-server-4'
5-
64
import type { Compiler, Configuration } from 'webpack'
75

86
import { createWebpackDevServer } from './createWebpackDevServer'
@@ -40,10 +38,6 @@ export type WebpackDevServerConfig = {
4038
* @internal
4139
*/
4240
type DevServerCreateResult = {
43-
version: 4
44-
server: WebpackDevServer4
45-
compiler: Compiler
46-
} | {
4741
version: 5
4842
server: WebpackDevServer5
4943
compiler: Compiler

npm/webpack-dev-server/src/helpers/sourceRelativeWebpackModules.ts

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ import debugFn from 'debug'
55

66
const debug = debugFn('cypress:webpack-dev-server:sourceRelativeWebpackModules')
77

8-
class CypressWebpackDevServerError extends Error {
9-
constructor (message: string) {
10-
super(message)
11-
this.name = 'CypressWebpackDevServerError'
12-
}
13-
}
14-
158
export type ModuleClass = typeof Module & {
169
_load(id: string, parent: Module, isMain: boolean): any
1710
_resolveFilename(request: string, parent: Module, isMain: boolean, options?: { paths: string[] }): string
@@ -147,7 +140,7 @@ export function sourceWebpack (config: WebpackDevServerConfig, framework: Source
147140
webpack.importPath = path.dirname(webpackJsonPath)
148141
webpack.packageJson = require(webpackJsonPath)
149142
webpack.module = require(webpack.importPath)
150-
webpack.majorVersion = getMajorVersion(webpack.packageJson, [4, 5])
143+
webpack.majorVersion = getMajorVersion(webpack.packageJson, [5])
151144

152145
debug('Webpack: Successfully sourced webpack - %o', webpack)
153146

@@ -211,25 +204,17 @@ export function sourceWebpackDevServer (config: WebpackDevServerConfig, webpackM
211204
webpackDevServer.importPath = path.dirname(webpackDevServerJsonPath)
212205
webpackDevServer.packageJson = require(webpackDevServerJsonPath)
213206
webpackDevServer.module = require(webpackDevServer.importPath)
214-
webpackDevServer.majorVersion = getMajorVersion(webpackDevServer.packageJson, [4, 5])
207+
webpackDevServer.majorVersion = getMajorVersion(webpackDevServer.packageJson, [5])
215208

216209
debug('WebpackDevServer: Successfully sourced webpack-dev-server - %o', webpackDevServer)
217-
if (webpackMajorVersion < 5 && webpackDevServer.majorVersion === 5) {
218-
const json = webpackDevServer.packageJson
219-
220-
throw new CypressWebpackDevServerError(
221-
`Incompatible major versions of webpack and webpack-dev-server!
222-
webpack-dev-server major version ${webpackDevServer.majorVersion} only works with major versions of webpack 5 - saw webpack-dev-server version ${json.version}.
223-
If using webpack major version 4, please install webpack-dev-server version 4 to be used with @cypress/webpack-dev-server or upgrade to webpack 5.`,
224-
)
225-
}
226210

227211
return webpackDevServer
228212
}
229213

230214
// Source the html-webpack-plugin module from the provided framework or projectRoot.
231215
// If none is found, we fallback to the version bundled with this package dependent on the major version of webpack.
232-
// We ship both v4 and v5 of 'html-webpack-plugin' by aliasing the package with the major version (check package.json).
216+
// We ship v5 of 'html-webpack-plugin' by aliasing the package with the major version (check package.json). This allows
217+
// us to support newer major versions of 'html-webpack-plugin' easily'.
233218
export function sourceHtmlWebpackPlugin (config: WebpackDevServerConfig, framework: SourcedDependency | null, webpack: SourcedWebpack): SourcedHtmlWebpackPlugin {
234219
const searchRoot = framework?.importPath ?? config.cypressConfig.projectRoot
235220

@@ -244,9 +229,9 @@ export function sourceHtmlWebpackPlugin (config: WebpackDevServerConfig, framewo
244229
})
245230

246231
htmlWebpackPlugin.packageJson = require(htmlWebpackPluginJsonPath)
247-
// Check that they're not using v3 of html-webpack-plugin. Since we should be the only consumer of it,
232+
// Check that they're not using v3 or v4 of html-webpack-plugin. Since we should be the only consumer of it,
248233
// we shouldn't be concerned with using our own copy if they've shipped w/ an earlier version
249-
htmlWebpackPlugin.majorVersion = getMajorVersion(htmlWebpackPlugin.packageJson, [4, 5])
234+
htmlWebpackPlugin.majorVersion = getMajorVersion(htmlWebpackPlugin.packageJson, [5])
250235
} catch (e) {
251236
const err = e as Error & {code?: string}
252237

npm/webpack-dev-server/test/devServer-unit.spec.ts

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,50 +14,6 @@ const cypressConfig = {
1414
describe('devServer', function () {
1515
this.timeout(10 * 1000)
1616

17-
it('creates a new devServer webpack4, webpackDevServer4', async () => {
18-
const { devServer } = proxyquire('../src/devServer', {
19-
'./helpers/sourceRelativeWebpackModules': {
20-
sourceDefaultWebpackDependencies: () => {
21-
return createModuleMatrixResult({
22-
webpack: 4,
23-
webpackDevServer: 4,
24-
})
25-
} },
26-
}) as typeof import('../src/devServer')
27-
28-
const result = await devServer.create({
29-
specs: [],
30-
cypressConfig,
31-
webpackConfig: {},
32-
devServerEvents: new EventEmitter(),
33-
})
34-
35-
expect(result.server).to.be.instanceOf(require('webpack-dev-server-4'))
36-
expect(result.version).to.eq(4)
37-
})
38-
39-
it('creates a new devServer webpack5, webpackDevServer4', async () => {
40-
const { devServer } = proxyquire('../src/devServer', {
41-
'./helpers/sourceRelativeWebpackModules': {
42-
sourceDefaultWebpackDependencies: () => {
43-
return createModuleMatrixResult({
44-
webpack: 5,
45-
webpackDevServer: 4,
46-
})
47-
} },
48-
}) as typeof import('../src/devServer')
49-
50-
const result = await devServer.create({
51-
specs: [],
52-
cypressConfig,
53-
webpackConfig: {},
54-
devServerEvents: new EventEmitter(),
55-
})
56-
57-
expect(result.server).to.be.instanceOf(require('webpack-dev-server-4'))
58-
expect(result.version).to.eq(4)
59-
})
60-
6117
it('creates a new devServer webpack5, webpackDevServer5', async () => {
6218
const { devServer } = proxyquire('../src/devServer', {
6319
'./helpers/sourceRelativeWebpackModules': {

0 commit comments

Comments
 (0)