@cypress/webpack-dev-server 3.2.2 → 3.2.4

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.
@@ -7,6 +7,7 @@ export interface CypressCTWebpackPluginOptions {
7
7
  supportFile: string | false;
8
8
  devServerEvents: EventEmitter;
9
9
  webpack: Function;
10
+ indexHtmlFile: string;
10
11
  }
11
12
  export declare type CypressCTContextOptions = Omit<CypressCTWebpackPluginOptions, 'devServerEvents' | 'webpack'>;
12
13
  export interface CypressCTWebpackContext {
@@ -23,6 +23,7 @@ class CypressCTWebpackPlugin {
23
23
  files: this.files,
24
24
  projectRoot: this.projectRoot,
25
25
  supportFile: this.supportFile,
26
+ indexHtmlFile: this.indexHtmlFile,
26
27
  };
27
28
  };
28
29
  this.beforeCompile = async (compilationParams, callback) => {
@@ -45,11 +46,16 @@ class CypressCTWebpackPlugin {
45
46
  callback();
46
47
  };
47
48
  /*
48
- * `webpack --watch` watches the existing specs and their dependencies for changes,
49
- * but we also need to add additional dependencies to our dynamic "browser.js" (generated
50
- * using loader.ts) when new specs are created. This hook informs webpack that browser.js
51
- * has been "updated on disk", causing a recompliation (and pulling the new specs in as
52
- * dependencies).
49
+ * `webpack --watch` watches the existing specs and their dependencies for changes.
50
+ * When new specs are created, we need to trigger a recompilation to add the new specs
51
+ * as dependencies. This hook informs webpack that `component-index.html` has been "updated on disk",
52
+ * causing a recompilation (and pulling the new specs in as dependencies). We use the component
53
+ * index file because we know that it will be there since the project is using Component Testing.
54
+ *
55
+ * We were using `browser.js` before to cause a recompilation but we ran into an
56
+ * issue with MacOS Ventura that will not allow us to write to files inside of our application bundle.
57
+ *
58
+ * See https://github.com/cypress-io/cypress/issues/24398
53
59
  */
54
60
  this.onSpecsChange = async (specs) => {
55
61
  var _a;
@@ -61,7 +67,7 @@ class CypressCTWebpackPlugin {
61
67
  // TODO: don't use a sync fs method here
62
68
  // eslint-disable-next-line no-restricted-syntax
63
69
  const utimesSync = (_a = inputFileSystem.fileSystem.utimesSync) !== null && _a !== void 0 ? _a : fs_extra_1.default.utimesSync;
64
- utimesSync(path_1.default.resolve(__dirname, 'browser.js'), new Date(), new Date());
70
+ utimesSync(path_1.default.join(this.projectRoot, this.indexHtmlFile), new Date(), new Date());
65
71
  };
66
72
  /**
67
73
  * The webpack compiler generates a new `compilation` each time it compiles, so
@@ -88,6 +94,7 @@ class CypressCTWebpackPlugin {
88
94
  this.projectRoot = options.projectRoot;
89
95
  this.devServerEvents = options.devServerEvents;
90
96
  this.webpack = options.webpack;
97
+ this.indexHtmlFile = options.indexHtmlFile;
91
98
  }
92
99
  /**
93
100
  * The plugin's entrypoint, called once by webpack when the compiler is initialized.
@@ -74,6 +74,7 @@ export declare function getAngularCliModules(projectRoot: string): Promise<{
74
74
  generateBrowserWebpackConfigFromContext: any;
75
75
  getCommonConfig: any;
76
76
  getStylesConfig: any;
77
+ logging: any;
77
78
  }>;
78
79
  export declare function getAngularJson(projectRoot: string): Promise<AngularJson>;
79
80
  export declare const toPosix: (filePath: string) => string;
@@ -8,7 +8,8 @@ const path = tslib_1.__importStar(require("path"));
8
8
  const dynamic_import_1 = require("../dynamic-import");
9
9
  const sourceRelativeWebpackModules_1 = require("./sourceRelativeWebpackModules");
10
10
  const debug_1 = tslib_1.__importDefault(require("debug"));
11
- const debug = (0, debug_1.default)('cypress:webpack-dev-server:angularHandler');
11
+ const debugPrefix = 'cypress:webpack-dev-server:angularHandler';
12
+ const debug = (0, debug_1.default)(debugPrefix);
12
13
  async function getProjectConfig(projectRoot) {
13
14
  var _a;
14
15
  const angularJson = await getAngularJson(projectRoot);
@@ -79,20 +80,22 @@ async function getAngularCliModules(projectRoot) {
79
80
  '@angular-devkit/build-angular/src/utils/webpack-browser-config.js',
80
81
  '@angular-devkit/build-angular/src/webpack/configs/common.js',
81
82
  '@angular-devkit/build-angular/src/webpack/configs/styles.js',
83
+ '@angular-devkit/core/src/index.js',
82
84
  ];
83
- const [{ generateBrowserWebpackConfigFromContext }, { getCommonConfig }, { getStylesConfig },] = await Promise.all(angularCLiModules.map((dep) => {
85
+ const [{ generateBrowserWebpackConfigFromContext }, { getCommonConfig }, { getStylesConfig }, { logging },] = await Promise.all(angularCLiModules.map((dep) => {
84
86
  try {
85
87
  const depPath = require.resolve(dep, { paths: [projectRoot] });
86
88
  return (0, dynamic_import_1.dynamicAbsoluteImport)(depPath);
87
89
  }
88
90
  catch (e) {
89
- throw new Error(`Could not resolve "${dep}". Do you have "@angular-devkit/build-angular" installed?`);
91
+ throw new Error(`Could not resolve "${dep}". Do you have "@angular-devkit/build-angular" and "@angular-devkit/core" installed?`);
90
92
  }
91
93
  }));
92
94
  return {
93
95
  generateBrowserWebpackConfigFromContext,
94
96
  getCommonConfig,
95
97
  getStylesConfig,
98
+ logging,
96
99
  };
97
100
  }
98
101
  exports.getAngularCliModules = getAngularCliModules;
@@ -106,14 +109,12 @@ async function getAngularJson(projectRoot) {
106
109
  return JSON.parse(angularJson);
107
110
  }
108
111
  exports.getAngularJson = getAngularJson;
109
- function createFakeContext(projectRoot, defaultProjectConfig) {
110
- const logger = {
111
- createChild: () => {
112
- return {
113
- warn: () => { },
114
- };
115
- },
116
- };
112
+ function createFakeContext(projectRoot, defaultProjectConfig, logging) {
113
+ const logger = new logging.Logger(debugPrefix);
114
+ // Proxy all logging calls through to the debug logger
115
+ logger.forEach((value) => {
116
+ debug(JSON.stringify(value));
117
+ });
117
118
  const context = {
118
119
  target: {
119
120
  project: 'angular',
@@ -135,12 +136,12 @@ exports.toPosix = toPosix;
135
136
  async function getAngularCliWebpackConfig(devServerConfig) {
136
137
  var _a;
137
138
  const { projectRoot } = devServerConfig.cypressConfig;
138
- const { generateBrowserWebpackConfigFromContext, getCommonConfig, getStylesConfig, } = await getAngularCliModules(projectRoot);
139
+ const { generateBrowserWebpackConfigFromContext, getCommonConfig, getStylesConfig, logging, } = await getAngularCliModules(projectRoot);
139
140
  // normalize
140
141
  const projectConfig = ((_a = devServerConfig.options) === null || _a === void 0 ? void 0 : _a.projectConfig) || await getProjectConfig(projectRoot);
141
142
  const tsConfig = await generateTsConfig(devServerConfig, projectConfig.buildOptions);
142
143
  const buildOptions = getAngularBuildOptions(projectConfig.buildOptions, tsConfig);
143
- const context = createFakeContext(projectRoot, projectConfig);
144
+ const context = createFakeContext(projectRoot, projectConfig, logging);
144
145
  const { config } = await generateBrowserWebpackConfigFromContext(buildOptions, context, (wco) => {
145
146
  const stylesConfig = getStylesConfig(wco);
146
147
  // We modify resolve-url-loader and set `root` to be `projectRoot` + `sourceRoot` to ensure
@@ -49,6 +49,7 @@ function makeCypressWebpackConfig(config) {
49
49
  devServerEvents,
50
50
  supportFile,
51
51
  webpack,
52
+ indexHtmlFile,
52
53
  }),
53
54
  ],
54
55
  devtool: 'inline-source-map',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cypress/webpack-dev-server",
3
- "version": "3.2.2",
3
+ "version": "3.2.4",
4
4
  "description": "Launches Webpack Dev Server for Component Testing",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {