@cypress/webpack-dev-server 5.1.5 → 5.2.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.
|
@@ -89,11 +89,13 @@ async function getAngularCliModules(projectRoot) {
|
|
|
89
89
|
];
|
|
90
90
|
const [{ generateBrowserWebpackConfigFromContext }, { getCommonConfig }, { getStylesConfig }, { logging },] = await Promise.all(angularCLiModules.map(async (dep) => {
|
|
91
91
|
try {
|
|
92
|
-
|
|
92
|
+
let depPath = require.resolve(dep, { paths: [projectRoot] });
|
|
93
93
|
// NOTE: @cypress/webpack-dev-server is a CJS package, but we need to import some ESM files and absolute imports.
|
|
94
94
|
// since import statements in TypeScript will get transpiled down to CommonJS require statements, we want to use tsx to leverage
|
|
95
95
|
// an ESM style import here, which supports CommonJS and ESM.
|
|
96
96
|
const { tsImport } = require('tsx/esm/api');
|
|
97
|
+
// NOTE: on Windows, fully qualified paths (ex: C:\Users\username\project\blah) need to be prefixed with `file://` to be properly resolved.
|
|
98
|
+
depPath = (0, os_1.platform)() === 'win32' ? `file://${(0, exports.toPosix)(depPath)}` : depPath;
|
|
97
99
|
const module = await tsImport(depPath, __filename);
|
|
98
100
|
return module;
|
|
99
101
|
}
|
|
@@ -6,6 +6,7 @@ const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
|
6
6
|
const module_1 = tslib_1.__importDefault(require("module"));
|
|
7
7
|
const fs = tslib_1.__importStar(require("fs"));
|
|
8
8
|
const path = tslib_1.__importStar(require("path"));
|
|
9
|
+
const semver_1 = tslib_1.__importDefault(require("semver"));
|
|
9
10
|
const sourceRelativeWebpackModules_1 = require("./sourceRelativeWebpackModules");
|
|
10
11
|
const debug = (0, debug_1.default)('cypress:webpack-dev-server-fresh:nextHandler');
|
|
11
12
|
async function nextHandler(devServerConfig) {
|
|
@@ -61,71 +62,12 @@ function getNextJsPackages(devServerConfig) {
|
|
|
61
62
|
}
|
|
62
63
|
/**
|
|
63
64
|
* Types for `getNextJsBaseWebpackConfig` based on version:
|
|
64
|
-
* -
|
|
65
|
+
* - v14.0.0, v15.0.0, and v16.0.0
|
|
65
66
|
[
|
|
66
67
|
dir: string,
|
|
67
|
-
options:
|
|
68
|
-
buildId: string
|
|
69
|
-
config: NextConfigComplete
|
|
70
|
-
dev?: boolean
|
|
71
|
-
isServer?: boolean
|
|
72
|
-
pagesDir: string
|
|
73
|
-
target?: string
|
|
74
|
-
reactProductionProfiling?: boolean
|
|
75
|
-
entrypoints: WebpackEntrypoints
|
|
76
|
-
rewrites: CustomRoutes['rewrites']
|
|
77
|
-
isDevFallback?: boolean
|
|
78
|
-
runWebpackSpan: Span
|
|
79
|
-
}
|
|
80
|
-
]
|
|
81
|
-
|
|
82
|
-
* - v12.0.0 = Same as v11.1.4
|
|
83
|
-
|
|
84
|
-
* - v12.1.6
|
|
85
|
-
[
|
|
86
|
-
dir: string,
|
|
87
|
-
options: {
|
|
88
|
-
buildId: string
|
|
89
|
-
config: NextConfigComplete
|
|
90
|
-
compilerType: 'client' | 'server' | 'edge-server'
|
|
91
|
-
dev?: boolean
|
|
92
|
-
entrypoints: webpack5.EntryObject
|
|
93
|
-
hasReactRoot: boolean
|
|
94
|
-
isDevFallback?: boolean
|
|
95
|
-
pagesDir: string
|
|
96
|
-
reactProductionProfiling?: boolean
|
|
97
|
-
rewrites: CustomRoutes['rewrites']
|
|
98
|
-
runWebpackSpan: Span
|
|
99
|
-
target?: string
|
|
100
|
-
}
|
|
101
|
-
]
|
|
102
|
-
|
|
103
|
-
* - v13.0.0
|
|
104
|
-
[
|
|
105
|
-
dir: string,
|
|
106
|
-
options: {
|
|
107
|
-
buildId: string
|
|
108
|
-
config: NextConfigComplete
|
|
109
|
-
compilerType: CompilerNameValues
|
|
110
|
-
dev?: boolean
|
|
111
|
-
entrypoints: webpack.EntryObject
|
|
112
|
-
hasReactRoot: boolean
|
|
113
|
-
isDevFallback?: boolean
|
|
114
|
-
pagesDir?: string
|
|
115
|
-
reactProductionProfiling?: boolean
|
|
116
|
-
rewrites: CustomRoutes['rewrites']
|
|
117
|
-
runWebpackSpan: Span
|
|
118
|
-
target?: string
|
|
119
|
-
appDir?: string
|
|
120
|
-
middlewareMatchers?: MiddlewareMatcher[]
|
|
121
|
-
}
|
|
122
|
-
]
|
|
123
|
-
|
|
124
|
-
* - v13.0.1
|
|
125
|
-
[
|
|
126
|
-
dir: string,
|
|
127
|
-
options: {
|
|
68
|
+
options: {
|
|
128
69
|
buildId: string
|
|
70
|
+
encryptionKey: string
|
|
129
71
|
config: NextConfigComplete
|
|
130
72
|
compilerType: CompilerNameValues
|
|
131
73
|
dev?: boolean
|
|
@@ -134,41 +76,27 @@ function getNextJsPackages(devServerConfig) {
|
|
|
134
76
|
pagesDir?: string
|
|
135
77
|
reactProductionProfiling?: boolean
|
|
136
78
|
rewrites: CustomRoutes['rewrites']
|
|
79
|
+
originalRewrites?: CustomRoutes['rewrites']
|
|
80
|
+
originalRedirects?: CustomRoutes['redirects']
|
|
137
81
|
runWebpackSpan: Span
|
|
138
|
-
target?: string
|
|
139
82
|
appDir?: string
|
|
140
|
-
middlewareMatchers?:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
runWebpackSpan: Span
|
|
158
|
-
target?: string
|
|
159
|
-
appDir?: string
|
|
160
|
-
middlewareMatchers?: MiddlewareMatcher[]
|
|
161
|
-
noMangling?: boolean
|
|
162
|
-
jsConfig: any
|
|
163
|
-
resolvedBaseUrl: string | undefined
|
|
164
|
-
supportedBrowsers: string[] | undefined
|
|
165
|
-
clientRouterFilters?: {
|
|
166
|
-
staticFilter: ReturnType<
|
|
167
|
-
import('../shared/lib/bloom-filter').BloomFilter['export']
|
|
168
|
-
>
|
|
169
|
-
dynamicFilter: ReturnType<
|
|
170
|
-
import('../shared/lib/bloom-filter').BloomFilter['export']
|
|
171
|
-
>
|
|
83
|
+
middlewareMatchers?: ProxyMatcher[]
|
|
84
|
+
noMangling?: boolean
|
|
85
|
+
jsConfig: any
|
|
86
|
+
jsConfigPath?: string
|
|
87
|
+
resolvedBaseUrl: ResolvedBaseUrl
|
|
88
|
+
supportedBrowsers: string[] | undefined
|
|
89
|
+
clientRouterFilters?: {
|
|
90
|
+
staticFilter: ReturnType<
|
|
91
|
+
import('../shared/lib/bloom-filter').BloomFilter['export']
|
|
92
|
+
>
|
|
93
|
+
dynamicFilter: ReturnType<
|
|
94
|
+
import('../shared/lib/bloom-filter').BloomFilter['export']
|
|
95
|
+
>
|
|
96
|
+
}
|
|
97
|
+
fetchCacheKeyPrefix?: string
|
|
98
|
+
isCompileMode?: boolean
|
|
99
|
+
previewProps: NonNullable<(typeof NextBuildContext)['previewProps']>;
|
|
172
100
|
}
|
|
173
101
|
}
|
|
174
102
|
]
|
|
@@ -186,7 +114,7 @@ async function loadWebpackConfig(devServerConfig) {
|
|
|
186
114
|
// Client webpack config for Next.js > 12.1.5
|
|
187
115
|
compilerType: 'client',
|
|
188
116
|
// Required for Next.js > 13
|
|
189
|
-
hasReactRoot: reactVersion
|
|
117
|
+
hasReactRoot: Boolean(reactVersion && reactVersion >= 18),
|
|
190
118
|
// Required for Next.js > 13.2.0 to respect TS/JS config
|
|
191
119
|
jsConfig: jsConfigResult.jsConfig,
|
|
192
120
|
// Required for Next.js > 13.2.0 to respect tsconfig.compilerOptions.baseUrl
|
|
@@ -289,29 +217,20 @@ function sourceNextWebpack(devServerConfig, framework) {
|
|
|
289
217
|
debug('NextWebpack: Failed to load NextWebpack - %s', e);
|
|
290
218
|
throw e;
|
|
291
219
|
}
|
|
292
|
-
// Next 11 allows the choice of webpack@4 or webpack@5, depending on the "webpack5" property in their next.config.js
|
|
293
|
-
// The webpackModule.init" for Next 11 returns a webpack@4 or webpack@4 compiler instance based on this boolean
|
|
294
|
-
let webpack5 = true;
|
|
295
220
|
const importPath = path.join(path.dirname(webpackJsonPath), 'webpack.js');
|
|
296
221
|
const webpackModule = require(importPath);
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
catch (e) {
|
|
305
|
-
// No next.config.js, assume webpack 5
|
|
222
|
+
// If Next.js is 16 and greater, webpack.js runs the required code previously inside init() on require().
|
|
223
|
+
// init() no longer exists and has the same affect on import, so we don't/can't invoke it
|
|
224
|
+
if (semver_1.default.lt(framework.packageJson.version, '16.0.0')) {
|
|
225
|
+
// for next 15 and down, we need to initialize the webpack module
|
|
226
|
+
webpackModule.init(true);
|
|
306
227
|
}
|
|
307
|
-
debug('NextWebpack: webpack5 - %s', webpack5);
|
|
308
|
-
webpackModule.init(webpack5);
|
|
309
228
|
const packageJson = require(webpackJsonPath);
|
|
310
229
|
webpack.importPath = importPath;
|
|
311
230
|
// The package.json of "next/dist/compiled/webpack/package.json" has no version so we supply the version for later use
|
|
312
|
-
webpack.packageJson = Object.assign(Object.assign({}, packageJson), { version:
|
|
231
|
+
webpack.packageJson = Object.assign(Object.assign({}, packageJson), { version: '5' });
|
|
313
232
|
webpack.module = webpackModule.webpack;
|
|
314
|
-
webpack.majorVersion = (0, sourceRelativeWebpackModules_1.getMajorVersion)(webpack.packageJson, [
|
|
233
|
+
webpack.majorVersion = (0, sourceRelativeWebpackModules_1.getMajorVersion)(webpack.packageJson, [5]);
|
|
315
234
|
debug('NextWebpack: Successfully loaded NextWebpack - %o', webpack);
|
|
316
235
|
module_1.default._load = function (request, parent, isMain) {
|
|
317
236
|
// Next with webpack@4 doesn't ship certain dependencies that HtmlWebpackPlugin requires, so we patch the resolution through to our bundled version
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cypress/webpack-dev-server",
|
|
3
|
-
"version": "5.1
|
|
3
|
+
"version": "5.2.1",
|
|
4
4
|
"description": "Launches Webpack Dev Server for Component Testing",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"fs-extra": "9.1.0",
|
|
22
22
|
"html-webpack-plugin-5": "npm:html-webpack-plugin@^5",
|
|
23
23
|
"local-pkg": "0.4.1",
|
|
24
|
-
"semver": "^7.7.
|
|
24
|
+
"semver": "^7.7.3",
|
|
25
25
|
"speed-measure-webpack-plugin": "1.4.2",
|
|
26
26
|
"tslib": "^2.3.1",
|
|
27
27
|
"tsx": "^4.20.6",
|