Commit d274a5b 1 parent a3fab73 commit d274a5b Copy full SHA for d274a5b
File tree 2 files changed +22
-0
lines changed
2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ const debug = require('debug')('@cypress/react')
4
4
const getNextJsBaseWebpackConfig = require ( 'next/dist/build/webpack-config' ) . default
5
5
const { findPagesDir } = require ( '../../dist/next/findPagesDir' )
6
6
const { getRunWebpackSpan } = require ( '../../dist/next/getRunWebpackSpan' )
7
+ const { checkSWC } = require ( '../../dist/next/checkSWC' )
7
8
8
9
async function getNextWebpackConfig ( config ) {
9
10
let loadConfig
@@ -38,6 +39,8 @@ async function getNextWebpackConfig (config) {
38
39
39
40
debug ( 'resolved next.js webpack config %o' , nextWebpackConfig )
40
41
42
+ checkSWC ( nextWebpackConfig , config )
43
+
41
44
return nextWebpackConfig
42
45
}
43
46
You can’t perform that action at this time.
0 commit comments