@cypress/webpack-dev-server 6.2.0 → 6.2.2

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.
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CypressCTWebpackPlugin = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const lodash_1 = tslib_1.__importDefault(require("lodash"));
6
5
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
7
6
  const path_1 = tslib_1.__importDefault(require("path"));
7
+ const node_util_1 = require("node:util");
8
8
  /**
9
9
  * A webpack 5 compatible Cypress Component Testing Plugin
10
10
  *
@@ -73,7 +73,7 @@ class CypressCTWebpackPlugin {
73
73
  * See https://github.com/cypress-io/cypress/issues/24398
74
74
  */
75
75
  onSpecsChange = async ({ specs, options }) => {
76
- if (!this.compilation || lodash_1.default.isEqual(specs, this.files)) {
76
+ if (!this.compilation || (0, node_util_1.isDeepStrictEqual)(specs, this.files)) {
77
77
  return;
78
78
  }
79
79
  this.files = specs;
@@ -8,6 +8,7 @@ const os_1 = require("os");
8
8
  const path = tslib_1.__importStar(require("path"));
9
9
  const sourceRelativeWebpackModules_1 = require("./sourceRelativeWebpackModules");
10
10
  const debug_1 = tslib_1.__importDefault(require("debug"));
11
+ const micromatch_1 = tslib_1.__importDefault(require("micromatch"));
11
12
  const debugPrefix = 'cypress:webpack-dev-server:angularHandler';
12
13
  const debug = (0, debug_1.default)(debugPrefix);
13
14
  async function getProjectConfig(projectRoot) {
@@ -85,7 +86,14 @@ async function generateTsConfig(devServerConfig, buildOptions) {
85
86
  const { workspaceRoot = projectRoot } = buildOptions;
86
87
  const specPattern = Array.isArray(cypressConfig.specPattern) ? cypressConfig.specPattern : [cypressConfig.specPattern];
87
88
  const getProjectFilePath = (...fileParts) => (0, exports.toPosix)(path.join(...fileParts));
88
- const includePaths = [...specPattern.map((pattern) => getProjectFilePath(projectRoot, pattern))];
89
+ // `**/*.cy.{ts,tsx}` becomes `**/*.cy.ts` and `**/*.cy.tsx`. TypeScript's
90
+ // `include` only understands `*`, `?` and `**/`, so a brace pattern, such as
91
+ // the default specPattern, would match no files. Expanding before joining
92
+ // projectRoot keeps braces in the project's own path literal. The result
93
+ // stays a list of globs rather than files because @ngtools/webpack re-reads
94
+ // `include` on every rebuild, which is how it picks up a newly created spec.
95
+ const expandedSpecPatterns = new Set(specPattern.flatMap((pattern) => micromatch_1.default.braces(pattern, { expand: true })));
96
+ const includePaths = [...expandedSpecPatterns].map((pattern) => getProjectFilePath(projectRoot, pattern));
89
97
  if (cypressConfig.supportFile) {
90
98
  includePaths.push((0, exports.toPosix)(cypressConfig.supportFile));
91
99
  }
@@ -159,19 +159,24 @@ const exists = async (file) => {
159
159
  /**
160
160
  * Next allows the `pages` directory to be located at either
161
161
  * `${projectRoot}/pages` or `${projectRoot}/src/pages`.
162
- * If neither is found, return projectRoot
162
+ * App Router-only projects have neither, so return `${projectRoot}/pages/` even
163
+ * though it doesn't exist. Next treats every file under `pagesDir` as a page and
164
+ * rejects `export *` in pages, so the project root would break dependencies such
165
+ * as `@mui/material`. Next's Babel loader also needs a path here when the project
166
+ * has a Babel config, so `undefined` won't do. The trailing separator keeps Next's
167
+ * `filename.startsWith(pagesDir)` check from matching siblings like `pages-legacy/`.
163
168
  */
164
169
  async function findPagesDir(projectRoot) {
165
170
  // prioritize ./pages over ./src/pages
166
- let pagesDir = path.join(projectRoot, 'pages');
171
+ const pagesDir = path.join(projectRoot, 'pages');
167
172
  if (await exists(pagesDir)) {
168
173
  return pagesDir;
169
174
  }
170
- pagesDir = path.join(projectRoot, 'src', 'pages');
171
- if (await exists(pagesDir)) {
172
- return pagesDir;
175
+ const srcPagesDir = path.join(projectRoot, 'src', 'pages');
176
+ if (await exists(srcPagesDir)) {
177
+ return srcPagesDir;
173
178
  }
174
- return projectRoot;
179
+ return `${pagesDir}${path.sep}`;
175
180
  }
176
181
  // 'next/dist/trace/trace' has been the trace location since Next.js 12.0
177
182
  function getRunWebpackSpan(devServerConfig) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cypress/webpack-dev-server",
3
- "version": "6.2.0",
3
+ "version": "6.2.2",
4
4
  "description": "Launches Webpack Dev Server for Component Testing",
5
5
  "homepage": "https://github.com/cypress-io/cypress/tree/develop/npm/webpack-dev-server#readme",
6
6
  "bugs": "https://github.com/cypress-io/cypress/issues/new?template=1-bug-report.md",
@@ -19,7 +19,7 @@
19
19
  "check-ts": "tsc --noEmit && tsc --project cypress/tsconfig.json",
20
20
  "clean": "rimraf dist",
21
21
  "cypress:open": "yarn cypress:run-cypress-in-cypress gulp open --project . --expose INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT=true",
22
- "cypress:run": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --project . --browser chrome --expose INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT=true",
22
+ "cypress:run": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress.mts run --project . --browser chrome --expose INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT=true",
23
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",
24
24
  "dev": "tsc --watch",
25
25
  "lint": "eslint",
@@ -34,6 +34,7 @@
34
34
  "fs-extra": "9.1.0",
35
35
  "html-webpack-plugin-5": "npm:html-webpack-plugin@^5",
36
36
  "local-pkg": "0.4.1",
37
+ "micromatch": "^4.0.8",
37
38
  "semver": "^7.7.3",
38
39
  "tslib": "^2.3.1",
39
40
  "tsx": "^4.23.12",
@@ -44,6 +45,8 @@
44
45
  "devDependencies": {
45
46
  "@angular-devkit/core": "^21.2.7",
46
47
  "@packages/eslint-config": "0.0.0-development",
48
+ "@packages/vitest-setup": "0.0.0-development",
49
+ "@types/micromatch": "4.0.10",
47
50
  "@types/node": "24.10.1",
48
51
  "@types/semver": "^7.5.0",
49
52
  "@types/webpack-bundle-analyzer": "4.7.0",