@nx/webpack 19.6.2 → 19.6.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.
package/index.d.ts CHANGED
@@ -22,3 +22,4 @@ export * from './src/utils/get-css-module-local-ident';
22
22
  export * from './src/utils/with-nx';
23
23
  export * from './src/utils/with-web';
24
24
  export * from './src/utils/module-federation/public-api';
25
+ export * from './src/utils/e2e-web-server-info-utils';
package/index.js CHANGED
@@ -29,3 +29,4 @@ tslib_1.__exportStar(require("./src/utils/get-css-module-local-ident"), exports)
29
29
  tslib_1.__exportStar(require("./src/utils/with-nx"), exports);
30
30
  tslib_1.__exportStar(require("./src/utils/with-web"), exports);
31
31
  tslib_1.__exportStar(require("./src/utils/module-federation/public-api"), exports);
32
+ tslib_1.__exportStar(require("./src/utils/e2e-web-server-info-utils"), exports);
package/migrations.json CHANGED
@@ -11,6 +11,12 @@
11
11
  "version": "17.2.1-beta.0",
12
12
  "description": "Add webpack.config.js file when webpackConfig is not defined",
13
13
  "implementation": "./src/migrations/update-17-2-1/webpack-config-setup"
14
+ },
15
+ "update-19-6-3-proxy-config": {
16
+ "cli": "nx",
17
+ "version": "19.6.3-beta.0",
18
+ "description": "Migrate proxy config files to match new format from webpack-dev-server v5.",
19
+ "implementation": "./src/migrations/update-19-6-3/proxy-config"
14
20
  }
15
21
  },
16
22
  "packageJsonUpdates": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/webpack",
3
- "version": "19.6.2",
3
+ "version": "19.6.4",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Webpack contains executors and generators that support building applications using Webpack.",
6
6
  "repository": {
@@ -69,9 +69,9 @@
69
69
  "webpack-dev-server": "^5.0.4",
70
70
  "webpack-node-externals": "^3.0.0",
71
71
  "webpack-subresource-integrity": "^5.1.0",
72
- "@nx/devkit": "19.6.2",
73
- "@nx/js": "19.6.2",
74
- "@nrwl/webpack": "19.6.2"
72
+ "@nx/devkit": "19.6.4",
73
+ "@nx/js": "19.6.4",
74
+ "@nrwl/webpack": "19.6.4"
75
75
  },
76
76
  "publishConfig": {
77
77
  "access": "public"
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export default function update(tree: Tree): Promise<void>;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = update;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
6
+ async function update(tree) {
7
+ const unmigratedConfigs = [];
8
+ const migrate = (options) => {
9
+ if (!options.proxyConfig)
10
+ return;
11
+ if (options.proxyConfig.endsWith('.json')) {
12
+ (0, devkit_1.updateJson)(tree, options.proxyConfig, (json) => {
13
+ if (Array.isArray(json))
14
+ return json;
15
+ if (typeof json === 'object') {
16
+ return Object.keys(json).map((context) => ({
17
+ context: [context],
18
+ ...json[context],
19
+ }));
20
+ }
21
+ return json;
22
+ });
23
+ }
24
+ else {
25
+ // For non-JSON files, it's not possible to automatically update the proxy config
26
+ // since its content can vary greatly.
27
+ unmigratedConfigs.push(options.proxyConfig);
28
+ }
29
+ };
30
+ (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/webpack:dev-server', migrate);
31
+ // React dev-server calls Webpack dev-server.
32
+ (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/react:module-federation-dev-server', migrate);
33
+ if (unmigratedConfigs.length > 0) {
34
+ devkit_1.logger.warn(`Some proxy config files need to be updated manually.
35
+ ${unmigratedConfigs.join('\n ')}
36
+
37
+ Webpack-dev-server v5 changed the proxy config schema to accept only an array.
38
+
39
+ For example, if you had the following:
40
+
41
+ "proxy": {
42
+ "/api": {
43
+ "target": "http://localhost:3000"
44
+ }
45
+ }
46
+
47
+ It needs to be updated to:
48
+
49
+ "proxy": [{
50
+ "context": ["/api"],
51
+ "target": "http://localhost:3000"
52
+ }]
53
+
54
+ More information: https://github.com/webpack/webpack-dev-server/blob/master/migration-v5.md
55
+ `);
56
+ }
57
+ }
@@ -0,0 +1,2 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export declare function getWebpackE2EWebServerInfo(tree: Tree, projectName: string, configFilePath: string, isPluginBeingAdded: boolean, e2ePortOverride?: number): Promise<import("@nx/devkit/src/generators/e2e-web-server-info-utils").E2EWebServerDetails>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWebpackE2EWebServerInfo = getWebpackE2EWebServerInfo;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const e2e_web_server_info_utils_1 = require("@nx/devkit/src/generators/e2e-web-server-info-utils");
6
+ async function getWebpackE2EWebServerInfo(tree, projectName, configFilePath, isPluginBeingAdded, e2ePortOverride) {
7
+ const nxJson = (0, devkit_1.readNxJson)(tree);
8
+ let e2ePort = e2ePortOverride ?? 4200;
9
+ if (nxJson.targetDefaults?.['serve'] &&
10
+ nxJson.targetDefaults?.['serve'].options?.port) {
11
+ e2ePort = nxJson.targetDefaults?.['serve'].options?.port;
12
+ }
13
+ return (0, e2e_web_server_info_utils_1.getE2EWebServerInfo)(tree, projectName, {
14
+ plugin: '@nx/webpack/plugin',
15
+ serveTargetName: 'serveTargetName',
16
+ serveStaticTargetName: 'serveStaticTargetName',
17
+ configFilePath,
18
+ }, {
19
+ defaultServeTargetName: 'serve',
20
+ defaultServeStaticTargetName: 'serve-static',
21
+ defaultE2EWebServerAddress: `http://localhost:${e2ePort}`,
22
+ defaultE2ECiBaseUrl: 'http://localhost:4200',
23
+ defaultE2EPort: e2ePort,
24
+ }, isPluginBeingAdded);
25
+ }