Skip to content

Commit df0d7e9

Browse files
committed
chore: add webpack 4 migration guide / workarounds
1 parent 4fa879e commit df0d7e9

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

docs/app/references/migration-guide.mdx

+66
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,72 @@ Cypress requires [Node.js](https://nodejs.org/en) in order to install the Cypres
2020
Node.js versions 18 and 23 are no longer supported.
2121
[See Node's release schedule](https://github.com/nodejs/Release).
2222

23+
### Webpack `4` is no longer supported
24+
25+
Cypress is no longer supporting Webpack `4` as it is no longer maintained by the core Webpack team and Webpack `5` has been available since Q4 2020. This includes Webpack `4` support for:
26+
27+
- `@cypress/webpack-dev-server` for component testing. This use case is most common and will require an update to Webpack `5`.
28+
- `@cypress/webpack-dev-server` also no longer supports [Webpack Dev Server v4](https://github.com/webpack/webpack-dev-server/tree/v4.15.2). We shipped [Webpack Dev Server v5](https://github.com/webpack/webpack-dev-server/tree/v5.2.1) as the default in Cypress 14 with `webpack-dev-server@4` being an option.
29+
- `@cypress/webpack-preprocessor` for end-to-end testing. Cypress, by default, uses the [Webpack Batteries Included Preprocessor](https://github.com/cypress-io/cypress/blob/@cypress/webpack-batteries-included-preprocessor-v3.0.7/npm/webpack-batteries-included-preprocessor/README.md) to process your files for end-to-end testing, which has used Webpack 5 since Cypress 13. Unless you are already using `@cypress/webpack-preprocessor` as a standalone package, this change likely does not apply.
30+
31+
#### To continue using Webpack `4`
32+
33+
##### Component Testing
34+
35+
If you haven't been able to migrate away from Webpack `4` or Webpack Dev Server `4` and still need to be able to run your component tests with Webpack `4` or Webpack Dev Server `4`, you can install the following packages independently:
36+
37+
```sh
38+
npm install --save-dev @cypress/webpack-dev-server@4.x.x
39+
```
40+
41+
and configure the dev server within your `cypress.config.js` or `cypress.config.ts` file:
42+
43+
```js
44+
import { devServer } from '@cypress/webpack-dev-server'
45+
import { defineConfig } from 'cypress'
46+
47+
export default defineConfig({
48+
component: {
49+
devServer(devServerConfig) {
50+
return devServer({
51+
...devServerConfig,
52+
framework: 'react',
53+
webpackConfig: require('./webpack.config.js'),
54+
})
55+
},
56+
},
57+
})
58+
```
59+
60+
Note that this package version is deprecated and no longer supported by Cypress and is intended as a workaround until you can migrate to Webpack `5`. More information on how to configure the dev server can be found in the [Cypress Webpack Dev Server documentation](https://github.com/cypress-io/cypress/blob/@cypress/webpack-dev-server-v4.0.2/npm/webpack-dev-server/README.md) and [Custom Dev Server documentation](/app/component-testing/component-framework-configuration#Custom-Dev-Server).
61+
62+
##### End-to-End Testing
63+
64+
If you haven't been able to migrate away from Webpack `4`, need custom end-to-end spec file preprocessing, are already using `@cypress/webpack-preprocessor` as a standalone package, and still need to be able to run your end-to-end tests with Webpack `4`, you can install the following package independently:
65+
66+
```sh
67+
npm install --save-dev @cypress/webpack-preprocessor@6.x.x
68+
```
69+
70+
and configure the preprocessor within your `cypress.config.js` or `cypress.config.ts` file:
71+
72+
```js
73+
import { defineConfig } from 'cypress'
74+
import webpackPreprocessor from '@cypress/webpack-preprocessor'
75+
76+
export default defineConfig({
77+
e2e: {
78+
setupNodeEvents(on, config) {
79+
on('file:preprocessor', webpackPreprocessor())
80+
},
81+
},
82+
})
83+
```
84+
85+
As stated earlier, this is likely unnecessary unless you are already using `@cypress/webpack-preprocessor` as a standalone package. Cypress by default uses the [Webpack Batteries Included Preprocessor](https://github.com/cypress-io/cypress/blob/@cypress/webpack-batteries-included-preprocessor-v3.0.7/npm/webpack-batteries-included-preprocessor/README.md) to process your spec files for end-to-end testing.
86+
87+
Note that this package version is deprecated and no longer supported by Cypress and is intended as a workaround until you can migrate to Webpack `5`. More information on how to configure the preprocessor can be found in the [Preprocessors API documentation](/api/node-events/preprocessors-api#Usage) and [Webpack Preprocessor documentation](https://github.com/cypress-io/cypress/blob/@cypress/webpack-preprocessor-v6.0.4/npm/webpack-preprocessor/README.md).
88+
2389
### Angular `17` CT no longer supported
2490

2591
With [LTS ending](https://angular.dev/reference/releases#actively-supported-versions) for Angular 17, the minimum required Angular version for component testing is now `18.0.0`.

0 commit comments

Comments
 (0)