@cypress/webpack-dev-server 3.0.1 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers/nextHandler.js +96 -1
- package/package.json +4 -3
|
@@ -44,15 +44,100 @@ function getNextJsPackages(devServerConfig) {
|
|
|
44
44
|
}
|
|
45
45
|
return packages;
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Types for `getNextJsBaseWebpackConfig` based on version:
|
|
49
|
+
* - v11.1.4
|
|
50
|
+
[
|
|
51
|
+
dir: string,
|
|
52
|
+
options: {
|
|
53
|
+
buildId: string
|
|
54
|
+
config: NextConfigComplete
|
|
55
|
+
dev?: boolean
|
|
56
|
+
isServer?: boolean
|
|
57
|
+
pagesDir: string
|
|
58
|
+
target?: string
|
|
59
|
+
reactProductionProfiling?: boolean
|
|
60
|
+
entrypoints: WebpackEntrypoints
|
|
61
|
+
rewrites: CustomRoutes['rewrites']
|
|
62
|
+
isDevFallback?: boolean
|
|
63
|
+
runWebpackSpan: Span
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
* - v12.0.0 = Same as v11.1.4
|
|
68
|
+
|
|
69
|
+
* - v12.1.6
|
|
70
|
+
[
|
|
71
|
+
dir: string,
|
|
72
|
+
options: {
|
|
73
|
+
buildId: string
|
|
74
|
+
config: NextConfigComplete
|
|
75
|
+
compilerType: 'client' | 'server' | 'edge-server'
|
|
76
|
+
dev?: boolean
|
|
77
|
+
entrypoints: webpack5.EntryObject
|
|
78
|
+
hasReactRoot: boolean
|
|
79
|
+
isDevFallback?: boolean
|
|
80
|
+
pagesDir: string
|
|
81
|
+
reactProductionProfiling?: boolean
|
|
82
|
+
rewrites: CustomRoutes['rewrites']
|
|
83
|
+
runWebpackSpan: Span
|
|
84
|
+
target?: string
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
|
|
88
|
+
* - v13.0.0
|
|
89
|
+
[
|
|
90
|
+
dir: string,
|
|
91
|
+
options: {
|
|
92
|
+
buildId: string
|
|
93
|
+
config: NextConfigComplete
|
|
94
|
+
compilerType: CompilerNameValues
|
|
95
|
+
dev?: boolean
|
|
96
|
+
entrypoints: webpack.EntryObject
|
|
97
|
+
hasReactRoot: boolean
|
|
98
|
+
isDevFallback?: boolean
|
|
99
|
+
pagesDir?: string
|
|
100
|
+
reactProductionProfiling?: boolean
|
|
101
|
+
rewrites: CustomRoutes['rewrites']
|
|
102
|
+
runWebpackSpan: Span
|
|
103
|
+
target?: string
|
|
104
|
+
appDir?: string
|
|
105
|
+
middlewareMatchers?: MiddlewareMatcher[]
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
* - v13.0.1
|
|
110
|
+
[
|
|
111
|
+
dir: string,
|
|
112
|
+
options: {
|
|
113
|
+
buildId: string
|
|
114
|
+
config: NextConfigComplete
|
|
115
|
+
compilerType: CompilerNameValues
|
|
116
|
+
dev?: boolean
|
|
117
|
+
entrypoints: webpack.EntryObject
|
|
118
|
+
isDevFallback?: boolean
|
|
119
|
+
pagesDir?: string
|
|
120
|
+
reactProductionProfiling?: boolean
|
|
121
|
+
rewrites: CustomRoutes['rewrites']
|
|
122
|
+
runWebpackSpan: Span
|
|
123
|
+
target?: string
|
|
124
|
+
appDir?: string
|
|
125
|
+
middlewareMatchers?: MiddlewareMatcher[]
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
*/
|
|
47
129
|
async function loadWebpackConfig(devServerConfig) {
|
|
48
130
|
const { loadConfig, getNextJsBaseWebpackConfig } = getNextJsPackages(devServerConfig);
|
|
49
131
|
const nextConfig = await loadConfig('development', devServerConfig.cypressConfig.projectRoot);
|
|
50
132
|
const runWebpackSpan = getRunWebpackSpan(devServerConfig);
|
|
133
|
+
const reactVersion = getReactVersion(devServerConfig.cypressConfig.projectRoot);
|
|
51
134
|
const webpackConfig = await getNextJsBaseWebpackConfig(devServerConfig.cypressConfig.projectRoot, Object.assign(Object.assign({ buildId: `@cypress/react-${Math.random().toString()}`, config: nextConfig, dev: true, pagesDir: await findPagesDir(devServerConfig.cypressConfig.projectRoot), entrypoints: {}, rewrites: { fallback: [], afterFiles: [], beforeFiles: [] } }, runWebpackSpan), {
|
|
52
135
|
// Client webpack config for Next.js <= 12.1.5
|
|
53
136
|
isServer: false,
|
|
54
137
|
// Client webpack config for Next.js > 12.1.5
|
|
55
|
-
compilerType: 'client'
|
|
138
|
+
compilerType: 'client',
|
|
139
|
+
// Required for Next.js > 13
|
|
140
|
+
hasReactRoot: reactVersion === 18 }));
|
|
56
141
|
return webpackConfig;
|
|
57
142
|
}
|
|
58
143
|
/**
|
|
@@ -234,3 +319,13 @@ function changeNextCachePath(webpackConfig) {
|
|
|
234
319
|
debug('Changing Next cache path from %s to %s', cacheDirectory, webpackConfig.cache.cacheDirectory);
|
|
235
320
|
}
|
|
236
321
|
}
|
|
322
|
+
function getReactVersion(projectRoot) {
|
|
323
|
+
try {
|
|
324
|
+
const reactPackageJsonPath = require.resolve('react/package.json', { paths: [projectRoot] });
|
|
325
|
+
const { version } = require(reactPackageJsonPath);
|
|
326
|
+
return Number(version.split('.')[0]);
|
|
327
|
+
}
|
|
328
|
+
catch (e) {
|
|
329
|
+
debug('Failed to source react with error: ', e);
|
|
330
|
+
}
|
|
331
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cypress/webpack-dev-server",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "Launches Webpack Dev Server for Component Testing",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -11,10 +11,11 @@
|
|
|
11
11
|
"dev": "tsc --watch",
|
|
12
12
|
"clean": "rimraf dist",
|
|
13
13
|
"cypress:run": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --project . --browser chrome",
|
|
14
|
-
"cypress:run-cypress-in-cypress": "cross-env HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS=http://localhost:4455 CYPRESS_REMOTE_DEBUGGING_PORT=6666 TZ=America/New_York",
|
|
14
|
+
"cypress:run-cypress-in-cypress": "cross-env CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT=1 HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS=http://localhost:4455 CYPRESS_REMOTE_DEBUGGING_PORT=6666 TZ=America/New_York",
|
|
15
15
|
"cypress:open": "yarn cypress:run-cypress-in-cypress gulp open --project .",
|
|
16
16
|
"test": "yarn test-unit",
|
|
17
|
-
"test-unit": "mocha -r ts-node/register/transpile-only --config ./test/.mocharc.js"
|
|
17
|
+
"test-unit": "mocha -r ts-node/register/transpile-only --config ./test/.mocharc.js",
|
|
18
|
+
"lint": "eslint --ext .js,.ts,.json, ."
|
|
18
19
|
},
|
|
19
20
|
"dependencies": {
|
|
20
21
|
"find-up": "6.3.0",
|