@cypress/webpack-dev-server 6.1.1 → 6.2.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.
- package/README.md +1 -0
- package/dist/CypressCTWebpackPlugin.d.ts +2 -1
- package/dist/CypressCTWebpackPlugin.js +18 -11
- package/dist/aut-runner.js +1 -2
- package/dist/createWebpackDevServer.js +3 -4
- package/dist/devServer.d.ts +1 -1
- package/dist/helpers/angularHandler.js +1 -1
- package/dist/helpers/nextHandler.js +5 -5
- package/dist/helpers/sourceRelativeWebpackModules.d.ts +4 -3
- package/dist/helpers/sourceRelativeWebpackModules.js +22 -7
- package/package.json +23 -14
package/README.md
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/// <reference types="cypress" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
+
import type webpack from 'webpack';
|
|
3
4
|
import type { EventEmitter } from 'events';
|
|
4
5
|
interface CypressCTWebpackPluginOptions {
|
|
5
6
|
files: Cypress.Cypress['spec'][];
|
|
6
7
|
projectRoot: string;
|
|
7
8
|
supportFile: string | false;
|
|
8
9
|
devServerEvents: EventEmitter;
|
|
9
|
-
webpack:
|
|
10
|
+
webpack: typeof webpack;
|
|
10
11
|
indexHtmlFile: string;
|
|
11
12
|
}
|
|
12
13
|
type CypressCTContextOptions = Omit<CypressCTWebpackPluginOptions, 'devServerEvents' | 'webpack'>;
|
|
@@ -39,17 +39,24 @@ class CypressCTWebpackPlugin {
|
|
|
39
39
|
callback();
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
42
|
+
let files;
|
|
43
|
+
let foundFiles;
|
|
44
|
+
// onSpecsChange can replace the list while the checks are pending. Checking again until
|
|
45
|
+
// the list holds still means this compile builds the newest list, filtered.
|
|
46
|
+
do {
|
|
47
|
+
files = this.files;
|
|
48
|
+
// Ensure we don't try to load files that have been removed from the file system
|
|
49
|
+
// but have not yet been detected by the onSpecsChange handler
|
|
50
|
+
foundFiles = await Promise.all(files.map(async (file) => {
|
|
51
|
+
try {
|
|
52
|
+
const exists = await fs_extra_1.default.pathExists(file.absolute);
|
|
53
|
+
return exists ? file : null;
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}));
|
|
59
|
+
} while (this.files !== files);
|
|
53
60
|
this.files = foundFiles.filter((file) => file !== null);
|
|
54
61
|
callback();
|
|
55
62
|
};
|
package/dist/aut-runner.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-env browser */
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.init = void 0;
|
|
5
4
|
function init(importPromises, parent = (window.opener || window.parent)) {
|
|
6
|
-
// @ts-expect-error
|
|
5
|
+
// @ts-expect-error - Cypress is attached to the window at runtime and is not on the Window type
|
|
7
6
|
const Cypress = window.Cypress = parent.Cypress;
|
|
8
7
|
if (!Cypress) {
|
|
9
8
|
throw new Error('Tests cannot run without a reference to Cypress!');
|
|
@@ -10,8 +10,8 @@ async function createWebpackDevServer(config) {
|
|
|
10
10
|
const { sourceWebpackModulesResult: { webpack: { module: webpack, }, webpackDevServer: { majorVersion: webpackDevServerMajorVersion, }, }, } = config;
|
|
11
11
|
const finalWebpackConfig = await (0, makeWebpackConfig_1.makeWebpackConfig)(config);
|
|
12
12
|
const webpackCompiler = webpack(finalWebpackConfig);
|
|
13
|
-
if (webpackDevServerMajorVersion === 5) {
|
|
14
|
-
debug(
|
|
13
|
+
if (webpackDevServerMajorVersion === 5 || webpackDevServerMajorVersion === 6) {
|
|
14
|
+
debug(`using webpack-dev-server v${webpackDevServerMajorVersion}`);
|
|
15
15
|
return webpackDevServer5(config, webpackCompiler, finalWebpackConfig);
|
|
16
16
|
}
|
|
17
17
|
throw new Error(`Unsupported webpackDevServer version ${webpackDevServerMajorVersion}`);
|
|
@@ -24,8 +24,7 @@ function webpackDevServer5(config, compiler, finalWebpackConfig) {
|
|
|
24
24
|
const webpackDevServerConfig = {
|
|
25
25
|
host: '127.0.0.1',
|
|
26
26
|
port: 'auto',
|
|
27
|
-
|
|
28
|
-
...finalWebpackConfig?.devServer,
|
|
27
|
+
...finalWebpackConfig.devServer,
|
|
29
28
|
devMiddleware: {
|
|
30
29
|
publicPath: devServerPublicPathRoute,
|
|
31
30
|
stats: finalWebpackConfig.stats ?? 'minimal',
|
package/dist/devServer.d.ts
CHANGED
|
@@ -145,7 +145,7 @@ async function getAngularCliModules(projectRoot) {
|
|
|
145
145
|
return module;
|
|
146
146
|
}
|
|
147
147
|
catch (e) {
|
|
148
|
-
throw new Error(`Could not resolve "${dep}". Do you have "@angular-devkit/build-angular" and "@angular-devkit/core" installed
|
|
148
|
+
throw new Error(`Could not resolve "${dep}". Do you have "@angular-devkit/build-angular" and "@angular-devkit/core" installed?`, { cause: e });
|
|
149
149
|
}
|
|
150
150
|
}));
|
|
151
151
|
return {
|
|
@@ -44,21 +44,21 @@ async function getNextJsPackages(devServerConfig) {
|
|
|
44
44
|
packages.loadConfig = require(loadConfigPath).default;
|
|
45
45
|
}
|
|
46
46
|
catch (e) {
|
|
47
|
-
throw new Error(`Failed to load "next/dist/server/config" with error: ${e.message ?? e}
|
|
47
|
+
throw new Error(`Failed to load "next/dist/server/config" with error: ${e.message ?? e}`, { cause: e });
|
|
48
48
|
}
|
|
49
49
|
try {
|
|
50
50
|
const getNextJsBaseWebpackConfigPath = require.resolve('next/dist/build/webpack-config', resolvePaths);
|
|
51
51
|
packages.getNextJsBaseWebpackConfig = require(getNextJsBaseWebpackConfigPath).default;
|
|
52
52
|
}
|
|
53
53
|
catch (e) {
|
|
54
|
-
throw new Error(`Failed to load "next/dist/build/webpack-config" with error: ${e.message ?? e}
|
|
54
|
+
throw new Error(`Failed to load "next/dist/build/webpack-config" with error: ${e.message ?? e}`, { cause: e });
|
|
55
55
|
}
|
|
56
56
|
try {
|
|
57
57
|
const loadJsConfigPath = require.resolve('next/dist/build/load-jsconfig', resolvePaths);
|
|
58
58
|
packages.nextLoadJsConfig = require(loadJsConfigPath).default;
|
|
59
59
|
}
|
|
60
60
|
catch (e) {
|
|
61
|
-
throw new Error(`Failed to load "next/dist/build/load-jsconfig" with error: ${e.message ?? e}
|
|
61
|
+
throw new Error(`Failed to load "next/dist/build/load-jsconfig" with error: ${e.message ?? e}`, { cause: e });
|
|
62
62
|
}
|
|
63
63
|
// Does not exist prior to Next 13.
|
|
64
64
|
try {
|
|
@@ -66,7 +66,7 @@ async function getNextJsPackages(devServerConfig) {
|
|
|
66
66
|
packages.getSupportedBrowsers = require(getUtilsPath).getSupportedBrowsers ?? (() => Promise.resolve([]));
|
|
67
67
|
}
|
|
68
68
|
catch (e) {
|
|
69
|
-
throw new Error(`Failed to load "next/dist/build/utils" with error: ${e.message ?? e}
|
|
69
|
+
throw new Error(`Failed to load "next/dist/build/utils" with error: ${e.message ?? e}`, { cause: e });
|
|
70
70
|
}
|
|
71
71
|
return packages;
|
|
72
72
|
}
|
|
@@ -188,7 +188,7 @@ const originalModuleLoad = module_1.default._load;
|
|
|
188
188
|
function sourceNextWebpackDeps(devServerConfig) {
|
|
189
189
|
const framework = (0, sourceRelativeWebpackModules_1.sourceFramework)(devServerConfig);
|
|
190
190
|
const webpack = sourceNextWebpack(devServerConfig, framework);
|
|
191
|
-
const webpackDevServer = (0, sourceRelativeWebpackModules_1.sourceWebpackDevServer)(devServerConfig, webpack
|
|
191
|
+
const webpackDevServer = (0, sourceRelativeWebpackModules_1.sourceWebpackDevServer)(devServerConfig, webpack, framework);
|
|
192
192
|
const htmlWebpackPlugin = (0, sourceRelativeWebpackModules_1.sourceHtmlWebpackPlugin)(devServerConfig, framework, webpack);
|
|
193
193
|
return {
|
|
194
194
|
framework,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import Module from 'module';
|
|
3
3
|
import type { WebpackDevServerConfig } from '../devServer';
|
|
4
|
+
import type webpack from 'webpack';
|
|
4
5
|
export type ModuleClass = typeof Module & {
|
|
5
6
|
_load(id: string, parent: Module, isMain: boolean): any;
|
|
6
7
|
_resolveFilename(request: string, parent: Module, isMain: boolean, options?: {
|
|
@@ -17,14 +18,14 @@ export interface SourcedDependency {
|
|
|
17
18
|
packageJson: PackageJson;
|
|
18
19
|
}
|
|
19
20
|
export interface SourcedWebpack extends SourcedDependency {
|
|
20
|
-
module:
|
|
21
|
+
module: typeof webpack;
|
|
21
22
|
majorVersion: 4 | 5;
|
|
22
23
|
}
|
|
23
24
|
interface SourcedWebpackDevServer extends SourcedDependency {
|
|
24
25
|
module: {
|
|
25
26
|
new (...args: unknown[]): unknown;
|
|
26
27
|
};
|
|
27
|
-
majorVersion: 4 | 5;
|
|
28
|
+
majorVersion: 4 | 5 | 6;
|
|
28
29
|
}
|
|
29
30
|
interface SourcedHtmlWebpackPlugin extends SourcedDependency {
|
|
30
31
|
module: unknown;
|
|
@@ -37,7 +38,7 @@ export interface SourceRelativeWebpackResult {
|
|
|
37
38
|
htmlWebpackPlugin: SourcedHtmlWebpackPlugin;
|
|
38
39
|
}
|
|
39
40
|
export declare function sourceFramework(config: WebpackDevServerConfig): SourcedDependency | null;
|
|
40
|
-
export declare function sourceWebpackDevServer(config: WebpackDevServerConfig,
|
|
41
|
+
export declare function sourceWebpackDevServer(config: WebpackDevServerConfig, webpack: SourcedWebpack, framework?: SourcedDependency | null): SourcedWebpackDevServer;
|
|
41
42
|
export declare function sourceHtmlWebpackPlugin(config: WebpackDevServerConfig, framework: SourcedDependency | null, webpack: SourcedWebpack): SourcedHtmlWebpackPlugin;
|
|
42
43
|
export declare function sourceDefaultWebpackDependencies(config: WebpackDevServerConfig): SourceRelativeWebpackResult;
|
|
43
44
|
export declare function getMajorVersion<T extends number>(json: PackageJson, acceptedVersions: T[]): T;
|
|
@@ -5,12 +5,20 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const module_1 = tslib_1.__importDefault(require("module"));
|
|
6
6
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
7
|
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
8
|
+
const semver_1 = tslib_1.__importDefault(require("semver"));
|
|
8
9
|
const debug = (0, debug_1.default)('cypress:webpack-dev-server:sourceRelativeWebpackModules');
|
|
10
|
+
class CypressWebpackDevServerError extends Error {
|
|
11
|
+
constructor(message) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = 'CypressWebpackDevServerError';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
9
16
|
const originalModuleLoad = module_1.default._load;
|
|
10
17
|
const originalModuleResolveFilename = module_1.default._resolveFilename;
|
|
11
18
|
// We ship webpack as part of '@cypress/webpack-batteries-included-preprocessor'. The path to this module
|
|
12
19
|
// serves as our fallback.
|
|
13
20
|
const cypressWebpackPath = (config) => {
|
|
21
|
+
// eslint-disable-next-line n/no-extraneous-require -- resolved from the Cypress binary, which ships it
|
|
14
22
|
return require.resolve('@cypress/webpack-batteries-included-preprocessor', {
|
|
15
23
|
paths: [config.cypressConfig.cypressBinaryRoot],
|
|
16
24
|
});
|
|
@@ -107,7 +115,7 @@ function sourceWebpack(config, framework) {
|
|
|
107
115
|
}
|
|
108
116
|
// Source the webpack-dev-server module from the provided framework or projectRoot.
|
|
109
117
|
// If none is found, we fallback to the version bundled with this package.
|
|
110
|
-
function sourceWebpackDevServer(config,
|
|
118
|
+
function sourceWebpackDevServer(config, webpack, framework) {
|
|
111
119
|
const searchRoot = framework?.importPath ?? config.cypressConfig.projectRoot;
|
|
112
120
|
debug('WebpackDevServer: Attempting to source webpack-dev-server from %s', searchRoot);
|
|
113
121
|
const webpackDevServer = {};
|
|
@@ -130,8 +138,14 @@ function sourceWebpackDevServer(config, webpackMajorVersion, framework) {
|
|
|
130
138
|
webpackDevServer.importPath = path_1.default.dirname(webpackDevServerJsonPath);
|
|
131
139
|
webpackDevServer.packageJson = require(webpackDevServerJsonPath);
|
|
132
140
|
webpackDevServer.module = require(webpackDevServer.importPath);
|
|
133
|
-
webpackDevServer.majorVersion = getMajorVersion(webpackDevServer.packageJson, [5]);
|
|
141
|
+
webpackDevServer.majorVersion = getMajorVersion(webpackDevServer.packageJson, [5, 6]);
|
|
134
142
|
debug('WebpackDevServer: Successfully sourced webpack-dev-server - %o', webpackDevServer);
|
|
143
|
+
// Next.js's compiled webpack only reports '5' as its version, so the minimum can't be checked there
|
|
144
|
+
if (webpackDevServer.majorVersion === 6 && semver_1.default.valid(webpack.packageJson.version) && semver_1.default.lt(webpack.packageJson.version, '5.101.0')) {
|
|
145
|
+
throw new CypressWebpackDevServerError('Incompatible versions of webpack and webpack-dev-server!\n' +
|
|
146
|
+
`webpack-dev-server ${webpackDevServer.packageJson.version} requires webpack 5.101.0 or newer, but found webpack ${webpack.packageJson.version}.\n` +
|
|
147
|
+
'Upgrade webpack to 5.101.0 or newer, or install webpack-dev-server 5 to use with @cypress/webpack-dev-server.');
|
|
148
|
+
}
|
|
135
149
|
return webpackDevServer;
|
|
136
150
|
}
|
|
137
151
|
exports.sourceWebpackDevServer = sourceWebpackDevServer;
|
|
@@ -145,6 +159,7 @@ function sourceHtmlWebpackPlugin(config, framework, webpack) {
|
|
|
145
159
|
const htmlWebpackPlugin = {};
|
|
146
160
|
let htmlWebpackPluginJsonPath;
|
|
147
161
|
try {
|
|
162
|
+
// eslint-disable-next-line n/no-extraneous-require -- sourced from the user's project, like webpack itself
|
|
148
163
|
htmlWebpackPluginJsonPath = require.resolve('html-webpack-plugin/package.json', {
|
|
149
164
|
paths: [searchRoot],
|
|
150
165
|
});
|
|
@@ -167,10 +182,10 @@ function sourceHtmlWebpackPlugin(config, framework, webpack) {
|
|
|
167
182
|
],
|
|
168
183
|
});
|
|
169
184
|
}
|
|
170
|
-
htmlWebpackPlugin.importPath = path_1.default.dirname(htmlWebpackPluginJsonPath)
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
185
|
+
htmlWebpackPlugin.importPath = path_1.default.dirname(htmlWebpackPluginJsonPath);
|
|
186
|
+
htmlWebpackPlugin.packageJson = require(htmlWebpackPluginJsonPath);
|
|
187
|
+
htmlWebpackPlugin.module = require(htmlWebpackPlugin.importPath);
|
|
188
|
+
htmlWebpackPlugin.majorVersion = getMajorVersion(htmlWebpackPlugin.packageJson, [4, 5]);
|
|
174
189
|
debug('HtmlWebpackPlugin: Successfully sourced html-webpack-plugin - %o', htmlWebpackPlugin);
|
|
175
190
|
return htmlWebpackPlugin;
|
|
176
191
|
}
|
|
@@ -179,7 +194,7 @@ exports.sourceHtmlWebpackPlugin = sourceHtmlWebpackPlugin;
|
|
|
179
194
|
function sourceDefaultWebpackDependencies(config) {
|
|
180
195
|
const framework = sourceFramework(config);
|
|
181
196
|
const webpack = sourceWebpack(config, framework);
|
|
182
|
-
const webpackDevServer = sourceWebpackDevServer(config, webpack
|
|
197
|
+
const webpackDevServer = sourceWebpackDevServer(config, webpack, framework);
|
|
183
198
|
const htmlWebpackPlugin = sourceHtmlWebpackPlugin(config, framework, webpack);
|
|
184
199
|
return {
|
|
185
200
|
framework,
|
package/package.json
CHANGED
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cypress/webpack-dev-server",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "Launches Webpack Dev Server for Component Testing",
|
|
5
|
+
"homepage": "https://github.com/cypress-io/cypress/tree/develop/npm/webpack-dev-server#readme",
|
|
6
|
+
"bugs": "https://github.com/cypress-io/cypress/issues/new?template=1-bug-report.md",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/cypress-io/cypress.git"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
5
12
|
"main": "dist/index.js",
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
6
16
|
"scripts": {
|
|
7
17
|
"prebuild": "rimraf dist",
|
|
8
18
|
"build": "tsc || echo 'built, with type errors'",
|
|
9
|
-
"check-ts": "tsc --noEmit",
|
|
19
|
+
"check-ts": "tsc --noEmit && tsc --project cypress/tsconfig.json",
|
|
10
20
|
"clean": "rimraf dist",
|
|
11
21
|
"cypress:open": "yarn cypress:run-cypress-in-cypress gulp open --project . --expose INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT=true",
|
|
12
22
|
"cypress:run": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --project . --browser chrome --expose INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT=true",
|
|
13
23
|
"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",
|
|
14
24
|
"dev": "tsc --watch",
|
|
15
|
-
"lint": "eslint
|
|
25
|
+
"lint": "eslint",
|
|
16
26
|
"test": "vitest run",
|
|
17
27
|
"test-debug": "vitest --inspect-brk --no-file-parallelism --test-timeout=0"
|
|
18
28
|
},
|
|
29
|
+
"lint-staged": {
|
|
30
|
+
"**/*.{js,jsx,ts,tsx,json}": "eslint --fix --no-warn-ignored"
|
|
31
|
+
},
|
|
19
32
|
"dependencies": {
|
|
20
33
|
"find-up": "6.3.0",
|
|
21
34
|
"fs-extra": "9.1.0",
|
|
@@ -29,26 +42,22 @@
|
|
|
29
42
|
"webpack-merge": "^5.4.0"
|
|
30
43
|
},
|
|
31
44
|
"devDependencies": {
|
|
45
|
+
"@angular-devkit/core": "^21.2.7",
|
|
46
|
+
"@packages/eslint-config": "0.0.0-development",
|
|
32
47
|
"@types/node": "24.10.1",
|
|
48
|
+
"@types/semver": "^7.5.0",
|
|
33
49
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
34
50
|
"cross-env": "7.0.3",
|
|
35
51
|
"dedent": "^0.7.0",
|
|
52
|
+
"eslint": "^10.14.0",
|
|
53
|
+
"jiti": "^2.4.2",
|
|
36
54
|
"vitest": "^3.2.4",
|
|
37
|
-
"webpack": "npm:webpack@^5"
|
|
55
|
+
"webpack": "npm:webpack@^5",
|
|
56
|
+
"webpack-dev-server-6": "npm:webpack-dev-server@^6"
|
|
38
57
|
},
|
|
39
58
|
"peerDependencies": {
|
|
40
59
|
"cypress": ">=15.0.0"
|
|
41
60
|
},
|
|
42
|
-
"files": [
|
|
43
|
-
"dist"
|
|
44
|
-
],
|
|
45
|
-
"license": "MIT",
|
|
46
|
-
"repository": {
|
|
47
|
-
"type": "git",
|
|
48
|
-
"url": "git+https://github.com/cypress-io/cypress.git"
|
|
49
|
-
},
|
|
50
|
-
"homepage": "https://github.com/cypress-io/cypress/tree/develop/npm/webpack-dev-server#readme",
|
|
51
|
-
"bugs": "https://github.com/cypress-io/cypress/issues/new?template=1-bug-report.md",
|
|
52
61
|
"publishConfig": {
|
|
53
62
|
"access": "public"
|
|
54
63
|
},
|