@cypress/webpack-dev-server 3.0.0 → 3.1.0
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.
|
@@ -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
|
+
}
|
|
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const debug_1 = require("debug");
|
|
6
6
|
const path = tslib_1.__importStar(require("path"));
|
|
7
7
|
const webpack_merge_1 = require("webpack-merge");
|
|
8
|
+
const local_pkg_1 = require("local-pkg");
|
|
8
9
|
const makeDefaultWebpackConfig_1 = require("./makeDefaultWebpackConfig");
|
|
9
10
|
const constants_1 = require("./constants");
|
|
10
11
|
const dynamic_import_1 = require("./dynamic-import");
|
|
@@ -68,7 +69,7 @@ async function makeWebpackConfig(config) {
|
|
|
68
69
|
const configFile = await getWebpackConfigFromProjectRoot(projectRoot);
|
|
69
70
|
if (configFile) {
|
|
70
71
|
debug('found webpack config %s', configFile);
|
|
71
|
-
const sourcedConfig = await (0,
|
|
72
|
+
const sourcedConfig = await (0, local_pkg_1.importModule)(configFile);
|
|
72
73
|
debug('config contains %o', sourcedConfig);
|
|
73
74
|
if (sourcedConfig && typeof sourcedConfig === 'object') {
|
|
74
75
|
userWebpackConfig = (_a = sourcedConfig.default) !== null && _a !== void 0 ? _a : sourcedConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cypress/webpack-dev-server",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Launches Webpack Dev Server for Component Testing",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"fs-extra": "9.1.0",
|
|
22
22
|
"html-webpack-plugin-4": "npm:html-webpack-plugin@^4",
|
|
23
23
|
"html-webpack-plugin-5": "npm:html-webpack-plugin@^5",
|
|
24
|
+
"local-pkg": "0.4.1",
|
|
24
25
|
"speed-measure-webpack-plugin": "1.4.2",
|
|
25
26
|
"tslib": "^2.3.1",
|
|
26
27
|
"webpack-dev-server": "^4.7.4",
|