Skip to content

Commit 56052c5

Browse files
authored
Merge branch 'master' into more-outdated-npm-registry-links
2 parents 5e2147b + 4d9fb6c commit 56052c5

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

npm/react/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# [@cypress/react-v5.10.3](https://github.com/cypress-io/cypress/compare/@cypress/react-v5.10.2...@cypress/react-v5.10.3) (2021-11-01)
2+
3+
4+
### Bug Fixes
5+
6+
* **@cypress/react:** throw if using Next.js swc-loader without nodeVersion=system ([#18686](https://github.com/cypress-io/cypress/issues/18686)) ([d274a5b](https://github.com/cypress-io/cypress/commit/d274a5b5d92323cb6a9c9d0af3e41bf40e679ac1))
7+
18
# [@cypress/react-v5.10.2](https://github.com/cypress-io/cypress/compare/@cypress/react-v5.10.1...@cypress/react-v5.10.2) (2021-10-29)
29

310

npm/react/plugins/next/checkSWC.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { Configuration } from 'webpack'
2+
3+
export function checkSWC (
4+
webpackConfig: Configuration,
5+
cypressConfig: Cypress.Config,
6+
) {
7+
const hasSWCLoader = webpackConfig.module?.rules.some((rule) => {
8+
return rule.oneOf?.some(
9+
(oneOf) => (oneOf.use as any)?.loader === 'next-swc-loader'
10+
)
11+
})
12+
13+
if (hasSWCLoader && cypressConfig.nodeVersion !== 'system') {
14+
throw new Error(`Cypress requires "nodeVersion" to be set to "system" in order to run Next.js with SWC optimizations.
15+
Please add "nodeVersion": "system" to your Cypress configuration and try again.`)
16+
}
17+
18+
return false
19+
}

npm/react/plugins/next/findNextWebpackConfig.js

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const debug = require('debug')('@cypress/react')
44
const getNextJsBaseWebpackConfig = require('next/dist/build/webpack-config').default
55
const { findPagesDir } = require('../../dist/next/findPagesDir')
66
const { getRunWebpackSpan } = require('../../dist/next/getRunWebpackSpan')
7+
const { checkSWC } = require('../../dist/next/checkSWC')
78

89
async function getNextWebpackConfig (config) {
910
let loadConfig
@@ -38,6 +39,8 @@ async function getNextWebpackConfig (config) {
3839

3940
debug('resolved next.js webpack config %o', nextWebpackConfig)
4041

42+
checkSWC(nextWebpackConfig, config)
43+
4144
return nextWebpackConfig
4245
}
4346

0 commit comments

Comments
 (0)