@cypress/webpack-dev-server 5.4.1 → 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.
@@ -1,7 +1,7 @@
1
1
  /// <reference types="cypress" />
2
2
  /// <reference types="node" />
3
3
  import type { EventEmitter } from 'events';
4
- export interface CypressCTWebpackPluginOptions {
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
- export type CypressCTContextOptions = Omit<CypressCTWebpackPluginOptions, 'devServerEvents' | 'webpack'>;
12
+ type CypressCTContextOptions = Omit<CypressCTWebpackPluginOptions, 'devServerEvents' | 'webpack'>;
13
13
  export interface CypressCTWebpackContext {
14
14
  _cypress: CypressCTContextOptions;
15
15
  }
16
- export declare const normalizeError: (error: Error | string) => string;
16
+ export {};
@@ -1,16 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CypressCTWebpackPlugin = exports.normalizeError = void 0;
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 4/5 compatible Cypress Component Testing Plugin
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.fileSystem.utimesSync) !== null && _a !== void 0 ? _a : fs_extra_1.default.utimesSync;
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 4 `compilation.Compilation`, webpack 5
78
- * `Compilation`
73
+ * @param compilation webpack 5 `Compilation`
79
74
  */
80
75
  this.addCompilationHooks = (compilation) => {
81
76
  this.compilation = compilation;
82
- /* istanbul ignore next */
83
- if ('NormalModule' in this.webpack) {
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;
@@ -41,5 +41,5 @@ export type PresetHandlerResult = {
41
41
  frameworkConfig: Configuration;
42
42
  sourceWebpackModulesResult: SourceRelativeWebpackResult;
43
43
  };
44
- export declare function isThirdPartyDefinition(framework: string): boolean;
44
+ /** @alias */
45
45
  export default devServer;
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.isThirdPartyDefinition = exports.devServer = void 0;
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;
@@ -9,7 +9,7 @@ type Configurations = {
9
9
  [configuration: string]: BuildOptions;
10
10
  };
11
11
  };
12
- export type AngularJsonProjectConfig = {
12
+ type AngularJsonProjectConfig = {
13
13
  projectType: string;
14
14
  root: string;
15
15
  sourceRoot: string;
@@ -8,7 +8,7 @@ export type ModuleClass = typeof Module & {
8
8
  }): string;
9
9
  _cache: Record<string, Module>;
10
10
  };
11
- export interface PackageJson {
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
- export interface SourcedWebpackDevServer extends SourcedDependency {
23
+ interface SourcedWebpackDevServer extends SourcedDependency {
24
24
  module: {
25
25
  new (...args: unknown[]): unknown;
26
26
  };
27
27
  majorVersion: 4 | 5;
28
28
  }
29
- export interface SourcedHtmlWebpackPlugin extends SourcedDependency {
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.sourceWebpack = exports.sourceFramework = exports.cypressWebpackPath = void 0;
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: () => new URLSearchParams(document.location.search).get("specPath") === "${file.absolute}",
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.4.1",
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",