@cypress/webpack-dev-server 3.5.1 → 3.5.3

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 CHANGED
@@ -68,6 +68,7 @@ We then merge the sourced config with the user's webpack config, and layer on ou
68
68
  | --------------------------- | ------- |
69
69
  | <= v1 | <= v9 |
70
70
  | >= v2 | >= v10 |
71
+ | >= v4 | >= v13 |
71
72
 
72
73
  ## License
73
74
 
package/dist/devServer.js CHANGED
@@ -22,9 +22,12 @@ const debug = (0, debug_1.default)('cypress:webpack-dev-server:devServer');
22
22
  */
23
23
  function devServer(devServerConfig) {
24
24
  return new Promise(async (resolve, reject) => {
25
+ var _a;
25
26
  const result = await devServer.create(devServerConfig);
27
+ // @ts-expect-error
28
+ const { port } = (_a = result.server) === null || _a === void 0 ? void 0 : _a.options;
26
29
  if (result.version === 3) {
27
- const srv = result.server.listen(0, '127.0.0.1', () => {
30
+ const srv = result.server.listen(port || 0, '127.0.0.1', () => {
28
31
  const port = srv.address().port;
29
32
  debug('Component testing webpack server 3 started on port %s', port);
30
33
  resolve({
@@ -207,6 +207,7 @@ function checkSWC(webpackConfig, cypressConfig) {
207
207
  });
208
208
  // "resolvedNodePath" is only set when using the user's Node.js, which is required to compile Next.js with SWC optimizations
209
209
  // If it is not set, they have either explicitly set "nodeVersion" to "bundled" or are are using Cypress < 9.0.0 where it was set to "bundled" by default
210
+ // @ts-expect-error nodeVersion has been removed as of 13.0.0 however this plugin can be used with many versions of cypress
210
211
  if (hasSWCLoader && cypressConfig.nodeVersion === 'bundled') {
211
212
  throw new Error(`Cypress cannot compile your Next.js application when "nodeVersion" is set to "bundled". Please remove this option from your Cypress configuration file.`);
212
213
  }
package/dist/loader.js CHANGED
@@ -16,7 +16,7 @@ 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: () => decodeURI(document.location.pathname).includes("${file.absolute}"),
19
+ shouldLoad: () => new URLSearchParams(document.location.search).get("specPath") === "${file.absolute}",
20
20
  load: () => import("${file.absolute}" ${magicComments}),
21
21
  absolute: "${file.absolute.split(path.sep).join(path.posix.sep)}",
22
22
  relative: "${file.relative.split(path.sep).join(path.posix.sep)}",
@@ -30,7 +30,7 @@ const makeImport = (file, filename, chunkName, projectRoot) => {
30
30
  * @returns {Record<string, ReturnType<makeImport>}
31
31
  * {
32
32
  * "App.spec.js": {
33
- * shouldLoad: () => document.location.pathname.includes("cypress/component/App.spec.js"),
33
+ * shouldLoad: () => (new URL(document.location)).searchParams.get("specPath") === "cypress/component/App.spec.js",
34
34
  * load: () => {
35
35
  * return import("/Users/projects/my-app/cypress/component/App.spec.js" \/* webpackChunkName: "spec-0" *\/)
36
36
  * },
@@ -10,7 +10,8 @@ const OUTPUT_PATH = path_1.default.join(__dirname, 'dist');
10
10
  const OsSeparatorRE = RegExp(`\\${path_1.default.sep}`, 'g');
11
11
  const posixSeparator = '/';
12
12
  function makeCypressWebpackConfig(config) {
13
- const { devServerConfig: { cypressConfig: { projectRoot, devServerPublicPathRoute, supportFile, indexHtmlFile, isTextTerminal: isRunMode, }, specs: files, devServerEvents, framework, }, sourceWebpackModulesResult: { webpack: { module: webpack, majorVersion: webpackMajorVersion, }, htmlWebpackPlugin: { module: HtmlWebpackPlugin, majorVersion: htmlWebpackPluginVersion, importPath: htmlWebpackPluginImportPath, }, webpackDevServer: { majorVersion: webpackDevServerMajorVersion, }, }, } = config;
13
+ const { devServerConfig: { cypressConfig: { port, projectRoot, devServerPublicPathRoute, supportFile, indexHtmlFile, isTextTerminal: isRunMode, }, specs: files, devServerEvents, framework, }, sourceWebpackModulesResult: { webpack: { module: webpack, majorVersion: webpackMajorVersion, }, htmlWebpackPlugin: { module: HtmlWebpackPlugin, majorVersion: htmlWebpackPluginVersion, importPath: htmlWebpackPluginImportPath, }, webpackDevServer: { majorVersion: webpackDevServerMajorVersion, }, }, } = config;
14
+ const webpackDevServerPort = port !== null && port !== void 0 ? port : undefined;
14
15
  debug(`Using HtmlWebpackPlugin version ${htmlWebpackPluginVersion} from ${htmlWebpackPluginImportPath}`);
15
16
  const optimization = {
16
17
  // To prevent files from being tree shaken by webpack, we set optimization.sideEffects: false ensuring that
@@ -42,7 +43,7 @@ function makeCypressWebpackConfig(config) {
42
43
  publicPath,
43
44
  },
44
45
  plugins: [
45
- new HtmlWebpackPlugin(Object.assign({ template: indexHtmlFile }, (framework === 'angular' ? { scriptLoading: 'module', base: '/__cypress/src/' } : {}))),
46
+ new HtmlWebpackPlugin(Object.assign({ template: indexHtmlFile ? path_1.default.join(projectRoot, indexHtmlFile) : undefined }, (framework === 'angular' ? { scriptLoading: 'module', base: '/__cypress/src/' } : {}))),
46
47
  new CypressCTWebpackPlugin_1.CypressCTWebpackPlugin({
47
48
  files,
48
49
  projectRoot,
@@ -62,6 +63,7 @@ function makeCypressWebpackConfig(config) {
62
63
  }
63
64
  if (webpackDevServerMajorVersion === 4) {
64
65
  return Object.assign(Object.assign({}, finalConfig), { devServer: {
66
+ port: webpackDevServerPort,
65
67
  client: {
66
68
  overlay: false,
67
69
  },
@@ -69,6 +71,7 @@ function makeCypressWebpackConfig(config) {
69
71
  }
70
72
  // @ts-ignore
71
73
  return Object.assign(Object.assign({}, finalConfig), { devServer: {
74
+ port: webpackDevServerPort,
72
75
  overlay: false,
73
76
  } });
74
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cypress/webpack-dev-server",
3
- "version": "3.5.1",
3
+ "version": "3.5.3",
4
4
  "description": "Launches Webpack Dev Server for Component Testing",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -30,6 +30,7 @@
30
30
  "webpack-merge": "^5.4.0"
31
31
  },
32
32
  "devDependencies": {
33
+ "@types/node": "16.18.39",
33
34
  "@types/proxyquire": "^1.3.28",
34
35
  "@types/speed-measure-webpack-plugin": "^1.3.4",
35
36
  "@types/webpack-dev-server-3": "npm:@types/webpack-dev-server@^3",