@cypress/webpack-dev-server 5.4.0 → 5.5.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/dist/CypressCTWebpackPlugin.d.ts +3 -3
- package/dist/CypressCTWebpackPlugin.js +6 -19
- package/dist/devServer.d.ts +1 -1
- package/dist/devServer.js +2 -2
- package/dist/helpers/angularHandler.d.ts +1 -1
- package/dist/helpers/nextHandler.js +19 -8
- package/dist/helpers/sourceRelativeWebpackModules.d.ts +4 -4
- package/dist/helpers/sourceRelativeWebpackModules.js +1 -2
- package/dist/loader.js +4 -1
- package/package.json +1 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="cypress" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import type { EventEmitter } from 'events';
|
|
4
|
-
|
|
4
|
+
interface CypressCTWebpackPluginOptions {
|
|
5
5
|
files: Cypress.Cypress['spec'][];
|
|
6
6
|
projectRoot: string;
|
|
7
7
|
supportFile: string | false;
|
|
@@ -9,8 +9,8 @@ export interface CypressCTWebpackPluginOptions {
|
|
|
9
9
|
webpack: Function;
|
|
10
10
|
indexHtmlFile: string;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
type CypressCTContextOptions = Omit<CypressCTWebpackPluginOptions, 'devServerEvents' | 'webpack'>;
|
|
13
13
|
export interface CypressCTWebpackContext {
|
|
14
14
|
_cypress: CypressCTContextOptions;
|
|
15
15
|
}
|
|
16
|
-
export
|
|
16
|
+
export {};
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CypressCTWebpackPlugin =
|
|
3
|
+
exports.CypressCTWebpackPlugin = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
6
6
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
7
7
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
|
-
const normalizeError = (error) => {
|
|
9
|
-
return typeof error === 'string' ? error : error.message;
|
|
10
|
-
};
|
|
11
|
-
exports.normalizeError = normalizeError;
|
|
12
8
|
/**
|
|
13
|
-
* A webpack
|
|
9
|
+
* A webpack 5 compatible Cypress Component Testing Plugin
|
|
14
10
|
*
|
|
15
11
|
* @internal
|
|
16
12
|
*/
|
|
@@ -66,7 +62,7 @@ class CypressCTWebpackPlugin {
|
|
|
66
62
|
const inputFileSystem = this.compilation.inputFileSystem;
|
|
67
63
|
// TODO: don't use a sync fs method here
|
|
68
64
|
// eslint-disable-next-line no-restricted-syntax
|
|
69
|
-
const utimesSync = (_a = inputFileSystem.
|
|
65
|
+
const utimesSync = (_a = inputFileSystem.utimesSync) !== null && _a !== void 0 ? _a : fs_extra_1.default.utimesSync;
|
|
70
66
|
const indexHtmlFilePath = path_1.default.isAbsolute(this.indexHtmlFile) ? this.indexHtmlFile : path_1.default.join(this.projectRoot, this.indexHtmlFile);
|
|
71
67
|
utimesSync(indexHtmlFilePath, new Date(), new Date());
|
|
72
68
|
};
|
|
@@ -74,21 +70,12 @@ class CypressCTWebpackPlugin {
|
|
|
74
70
|
* The webpack compiler generates a new `compilation` each time it compiles, so
|
|
75
71
|
* we have to apply hooks to it fresh each time
|
|
76
72
|
*
|
|
77
|
-
* @param compilation webpack
|
|
78
|
-
* `Compilation`
|
|
73
|
+
* @param compilation webpack 5 `Compilation`
|
|
79
74
|
*/
|
|
80
75
|
this.addCompilationHooks = (compilation) => {
|
|
81
76
|
this.compilation = compilation;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
// Webpack 5
|
|
85
|
-
const loader = this.webpack.NormalModule.getCompilationHooks(compilation).loader;
|
|
86
|
-
loader.tap('CypressCTPlugin', this.addLoaderContext);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
// Webpack 4
|
|
90
|
-
compilation.hooks.normalModuleLoader.tap('CypressCTPlugin', this.addLoaderContext);
|
|
91
|
-
}
|
|
77
|
+
const loader = this.webpack.NormalModule.getCompilationHooks(compilation).loader;
|
|
78
|
+
loader.tap('CypressCTPlugin', this.addLoaderContext);
|
|
92
79
|
};
|
|
93
80
|
this.files = options.files;
|
|
94
81
|
this.supportFile = options.supportFile;
|
package/dist/devServer.d.ts
CHANGED
package/dist/devServer.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/// <reference types="cypress" />
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports.devServer = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const createWebpackDevServer_1 = require("./createWebpackDevServer");
|
|
7
7
|
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
@@ -48,7 +48,6 @@ function isThirdPartyDefinition(framework) {
|
|
|
48
48
|
return framework.startsWith(thirdPartyDefinitionPrefixes.globalPrefix) ||
|
|
49
49
|
thirdPartyDefinitionPrefixes.namespacedPrefixRe.test(framework);
|
|
50
50
|
}
|
|
51
|
-
exports.isThirdPartyDefinition = isThirdPartyDefinition;
|
|
52
51
|
async function getPreset(devServerConfig) {
|
|
53
52
|
const defaultWebpackModules = () => ({ sourceWebpackModulesResult: (0, sourceRelativeWebpackModules_1.sourceDefaultWebpackDependencies)(devServerConfig) });
|
|
54
53
|
// Third party library (eg solid-js, lit, etc)
|
|
@@ -89,4 +88,5 @@ devServer.create = async function (devServerConfig) {
|
|
|
89
88
|
};
|
|
90
89
|
return result;
|
|
91
90
|
};
|
|
91
|
+
/** @alias */
|
|
92
92
|
exports.default = devServer;
|
|
@@ -25,38 +25,49 @@ exports.nextHandler = nextHandler;
|
|
|
25
25
|
* `loadConfig` acquires the next.config.js
|
|
26
26
|
* `getNextJsBaseWebpackConfig` acquires the webpackConfig dependent on the next.config.js
|
|
27
27
|
*/
|
|
28
|
-
function getNextJsPackages(devServerConfig) {
|
|
29
|
-
var _a, _b, _c, _d, _e;
|
|
28
|
+
async function getNextJsPackages(devServerConfig) {
|
|
29
|
+
var _a, _b, _c, _d, _e, _f;
|
|
30
30
|
const resolvePaths = { paths: [devServerConfig.cypressConfig.projectRoot] };
|
|
31
31
|
const packages = {};
|
|
32
|
+
// Starting with Next.js 16.0.3, we need to proactively install SWC bindings
|
|
33
|
+
// See: https://github.com/vercel/next.js/pull/85787
|
|
34
|
+
try {
|
|
35
|
+
const installBindingsPath = require.resolve('next/dist/build/swc/install-bindings', resolvePaths);
|
|
36
|
+
const { installBindings } = require(installBindingsPath);
|
|
37
|
+
await installBindings();
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
// installBindings doesn't exist in Next.js < 16.0.3, which is fine
|
|
41
|
+
debug('installBindings not available (Next.js < 16.0.3): %s', (_a = e.message) !== null && _a !== void 0 ? _a : e);
|
|
42
|
+
}
|
|
32
43
|
try {
|
|
33
44
|
const loadConfigPath = require.resolve('next/dist/server/config', resolvePaths);
|
|
34
45
|
packages.loadConfig = require(loadConfigPath).default;
|
|
35
46
|
}
|
|
36
47
|
catch (e) {
|
|
37
|
-
throw new Error(`Failed to load "next/dist/server/config" with error: ${(
|
|
48
|
+
throw new Error(`Failed to load "next/dist/server/config" with error: ${(_b = e.message) !== null && _b !== void 0 ? _b : e}`);
|
|
38
49
|
}
|
|
39
50
|
try {
|
|
40
51
|
const getNextJsBaseWebpackConfigPath = require.resolve('next/dist/build/webpack-config', resolvePaths);
|
|
41
52
|
packages.getNextJsBaseWebpackConfig = require(getNextJsBaseWebpackConfigPath).default;
|
|
42
53
|
}
|
|
43
54
|
catch (e) {
|
|
44
|
-
throw new Error(`Failed to load "next/dist/build/webpack-config" with error: ${(
|
|
55
|
+
throw new Error(`Failed to load "next/dist/build/webpack-config" with error: ${(_c = e.message) !== null && _c !== void 0 ? _c : e}`);
|
|
45
56
|
}
|
|
46
57
|
try {
|
|
47
58
|
const loadJsConfigPath = require.resolve('next/dist/build/load-jsconfig', resolvePaths);
|
|
48
59
|
packages.nextLoadJsConfig = require(loadJsConfigPath).default;
|
|
49
60
|
}
|
|
50
61
|
catch (e) {
|
|
51
|
-
throw new Error(`Failed to load "next/dist/build/load-jsconfig" with error: ${(
|
|
62
|
+
throw new Error(`Failed to load "next/dist/build/load-jsconfig" with error: ${(_d = e.message) !== null && _d !== void 0 ? _d : e}`);
|
|
52
63
|
}
|
|
53
64
|
// Does not exist prior to Next 13.
|
|
54
65
|
try {
|
|
55
66
|
const getUtilsPath = require.resolve('next/dist/build/utils', resolvePaths);
|
|
56
|
-
packages.getSupportedBrowsers = (
|
|
67
|
+
packages.getSupportedBrowsers = (_e = require(getUtilsPath).getSupportedBrowsers) !== null && _e !== void 0 ? _e : (() => Promise.resolve([]));
|
|
57
68
|
}
|
|
58
69
|
catch (e) {
|
|
59
|
-
throw new Error(`Failed to load "next/dist/build/utils" with error: ${(
|
|
70
|
+
throw new Error(`Failed to load "next/dist/build/utils" with error: ${(_f = e.message) !== null && _f !== void 0 ? _f : e}`);
|
|
60
71
|
}
|
|
61
72
|
return packages;
|
|
62
73
|
}
|
|
@@ -102,7 +113,7 @@ function getNextJsPackages(devServerConfig) {
|
|
|
102
113
|
]
|
|
103
114
|
*/
|
|
104
115
|
async function loadWebpackConfig(devServerConfig) {
|
|
105
|
-
const { loadConfig, getNextJsBaseWebpackConfig, nextLoadJsConfig, getSupportedBrowsers } = getNextJsPackages(devServerConfig);
|
|
116
|
+
const { loadConfig, getNextJsBaseWebpackConfig, nextLoadJsConfig, getSupportedBrowsers } = await getNextJsPackages(devServerConfig);
|
|
106
117
|
const nextConfig = await loadConfig('development', devServerConfig.cypressConfig.projectRoot);
|
|
107
118
|
const runWebpackSpan = getRunWebpackSpan(devServerConfig);
|
|
108
119
|
const reactVersion = getReactVersion(devServerConfig.cypressConfig.projectRoot);
|
|
@@ -8,7 +8,7 @@ export type ModuleClass = typeof Module & {
|
|
|
8
8
|
}): string;
|
|
9
9
|
_cache: Record<string, Module>;
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
interface PackageJson {
|
|
12
12
|
name: string;
|
|
13
13
|
version: string;
|
|
14
14
|
}
|
|
@@ -20,13 +20,13 @@ export interface SourcedWebpack extends SourcedDependency {
|
|
|
20
20
|
module: Function;
|
|
21
21
|
majorVersion: 4 | 5;
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
interface SourcedWebpackDevServer extends SourcedDependency {
|
|
24
24
|
module: {
|
|
25
25
|
new (...args: unknown[]): unknown;
|
|
26
26
|
};
|
|
27
27
|
majorVersion: 4 | 5;
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
interface SourcedHtmlWebpackPlugin extends SourcedDependency {
|
|
30
30
|
module: unknown;
|
|
31
31
|
majorVersion: 4 | 5;
|
|
32
32
|
}
|
|
@@ -38,9 +38,9 @@ export interface SourceRelativeWebpackResult {
|
|
|
38
38
|
}
|
|
39
39
|
export declare const cypressWebpackPath: (config: WebpackDevServerConfig) => string;
|
|
40
40
|
export declare function sourceFramework(config: WebpackDevServerConfig): SourcedDependency | null;
|
|
41
|
-
export declare function sourceWebpack(config: WebpackDevServerConfig, framework: SourcedDependency | null): SourcedWebpack;
|
|
42
41
|
export declare function sourceWebpackDevServer(config: WebpackDevServerConfig, webpackMajorVersion: 4 | 5, framework?: SourcedDependency | null): SourcedWebpackDevServer;
|
|
43
42
|
export declare function sourceHtmlWebpackPlugin(config: WebpackDevServerConfig, framework: SourcedDependency | null, webpack: SourcedWebpack): SourcedHtmlWebpackPlugin;
|
|
44
43
|
export declare function sourceDefaultWebpackDependencies(config: WebpackDevServerConfig): SourceRelativeWebpackResult;
|
|
45
44
|
export declare function getMajorVersion<T extends number>(json: PackageJson, acceptedVersions: T[]): T;
|
|
46
45
|
export declare function restoreLoadHook(): void;
|
|
46
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.restoreLoadHook = exports.getMajorVersion = exports.sourceDefaultWebpackDependencies = exports.sourceHtmlWebpackPlugin = exports.sourceWebpackDevServer = exports.
|
|
3
|
+
exports.restoreLoadHook = exports.getMajorVersion = exports.sourceDefaultWebpackDependencies = exports.sourceHtmlWebpackPlugin = exports.sourceWebpackDevServer = exports.sourceFramework = exports.cypressWebpackPath = void 0;
|
|
4
4
|
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"));
|
|
@@ -107,7 +107,6 @@ function sourceWebpack(config, framework) {
|
|
|
107
107
|
};
|
|
108
108
|
return webpack;
|
|
109
109
|
}
|
|
110
|
-
exports.sourceWebpack = sourceWebpack;
|
|
111
110
|
// Source the webpack-dev-server module from the provided framework or projectRoot.
|
|
112
111
|
// If none is found, we fallback to the version bundled with this package.
|
|
113
112
|
function sourceWebpackDevServer(config, webpackMajorVersion, framework) {
|
package/dist/loader.js
CHANGED
|
@@ -16,7 +16,10 @@ const makeImport = (file, filename, chunkName, projectRoot) => {
|
|
|
16
16
|
// If we want to rename the chunks, we can use this
|
|
17
17
|
const magicComments = chunkName ? `/* webpackChunkName: "${chunkName}" */` : '';
|
|
18
18
|
return `"${filename}": {
|
|
19
|
-
shouldLoad: () =>
|
|
19
|
+
shouldLoad: () => {
|
|
20
|
+
const specPath = new URLSearchParams(document.location.search).get("specPath")
|
|
21
|
+
return specPath === "__all" || specPath === "${file.absolute}"
|
|
22
|
+
},
|
|
20
23
|
load: () => import("${file.absolute}" ${magicComments}),
|
|
21
24
|
absolute: "${file.absolute.split(path.sep).join(path.posix.sep)}",
|
|
22
25
|
relative: "${file.relative.split(path.sep).join(path.posix.sep)}",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cypress/webpack-dev-server",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"description": "Launches Webpack Dev Server for Component Testing",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
"html-webpack-plugin-5": "npm:html-webpack-plugin@^5",
|
|
23
23
|
"local-pkg": "0.4.1",
|
|
24
24
|
"semver": "^7.7.3",
|
|
25
|
-
"speed-measure-webpack-plugin": "1.4.2",
|
|
26
25
|
"tslib": "^2.3.1",
|
|
27
26
|
"tsx": "^4.20.6",
|
|
28
27
|
"webpack-bundle-analyzer": "4.10.2",
|
|
@@ -31,7 +30,6 @@
|
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
|
33
32
|
"@types/node": "22.18.7",
|
|
34
|
-
"@types/speed-measure-webpack-plugin": "^1.3.4",
|
|
35
33
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
36
34
|
"cross-env": "7.0.3",
|
|
37
35
|
"dedent": "^0.7.0",
|