@nx/angular 17.3.1 → 17.3.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.
package/migrations.json CHANGED
@@ -356,6 +356,12 @@
356
356
  },
357
357
  "description": "Add 'autoprefixer' as dev dependency when '@nx/angular:ng-packagr-lite' or '@nx/angular:package` is used.",
358
358
  "factory": "./src/migrations/update-17-3-0/add-autoprefixer-dependency"
359
+ },
360
+ "add-module-federation-env-var-to-target-defaults": {
361
+ "cli": "nx",
362
+ "version": "18.0.0-beta.0",
363
+ "description": "Add NX_MF_DEV_SERVER_STATIC_REMOTES to inputs for task hashing when '@nx/angular:webpack-browser' is used for Module Federation.",
364
+ "factory": "./src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults"
359
365
  }
360
366
  },
361
367
  "packageJsonUpdates": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/angular",
3
- "version": "17.3.1",
3
+ "version": "17.3.2",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: \n\n- Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, and Cypress. \n\n- Generators to help scaffold code quickly (like: Micro Frontends, Libraries, both internal to your codebase and publishable to npm) \n\n- Upgrading AngularJS applications \n\n- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
6
6
  "repository": {
@@ -74,20 +74,20 @@
74
74
  "ignore": "^5.0.4",
75
75
  "magic-string": "~0.30.2",
76
76
  "minimatch": "9.0.3",
77
- "semver": "7.5.3",
77
+ "semver": "^7.5.3",
78
78
  "tslib": "^2.3.0",
79
79
  "webpack": "^5.80.0",
80
80
  "webpack-merge": "^5.8.0",
81
- "@nx/devkit": "17.3.1",
82
- "@nx/cypress": "17.3.1",
83
- "@nx/jest": "17.3.1",
84
- "@nx/js": "17.3.1",
85
- "@nx/eslint": "17.3.1",
86
- "@nx/webpack": "17.3.1",
87
- "@nx/web": "17.3.1",
88
- "@nx/workspace": "17.3.1",
81
+ "@nx/devkit": "17.3.2",
82
+ "@nx/cypress": "17.3.2",
83
+ "@nx/jest": "17.3.2",
84
+ "@nx/js": "17.3.2",
85
+ "@nx/eslint": "17.3.2",
86
+ "@nx/webpack": "17.3.2",
87
+ "@nx/web": "17.3.2",
88
+ "@nx/workspace": "17.3.2",
89
89
  "piscina": "^4.2.1",
90
- "@nrwl/angular": "17.3.1"
90
+ "@nrwl/angular": "17.3.2"
91
91
  },
92
92
  "peerDependencies": {
93
93
  "@angular-devkit/build-angular": ">= 15.0.0 < 18.0.0",
@@ -29,8 +29,9 @@ export declare function nxComponentTestingPreset(pathToConfig: string, options?:
29
29
  customWebpackConfig?: {
30
30
  path: string;
31
31
  };
32
- indexFileTransformer?: string;
32
+ indexHtmlTransformer?: string;
33
33
  buildLibsFromSource?: boolean;
34
+ indexFileTransformer?: string;
34
35
  } & {
35
36
  workspaceRoot: string;
36
37
  };
@@ -54,9 +54,11 @@ function executeDevServerBuilder(rawOptions, context) {
54
54
  throw new Error(`Custom Webpack Config File Not Found!\nTo use a custom webpack config, please ensure the path to the custom webpack file is correct: \n${pathToWebpackConfig}`);
55
55
  }
56
56
  }
57
+ const normalizedIndexHtmlTransformer = buildTargetOptions.indexHtmlTransformer ??
58
+ buildTargetOptions.indexFileTransformer;
57
59
  let pathToIndexFileTransformer;
58
- if (buildTargetOptions.indexFileTransformer) {
59
- pathToIndexFileTransformer = (0, devkit_1.joinPathFragments)(context.workspaceRoot, buildTargetOptions.indexFileTransformer);
60
+ if (normalizedIndexHtmlTransformer) {
61
+ pathToIndexFileTransformer = (0, devkit_1.joinPathFragments)(context.workspaceRoot, normalizedIndexHtmlTransformer);
60
62
  if (pathToIndexFileTransformer && !(0, fs_1.existsSync)(pathToIndexFileTransformer)) {
61
63
  throw new Error(`File containing Index File Transformer function Not Found!\n Please ensure the path to the file containing the function is correct: \n${pathToIndexFileTransformer}`);
62
64
  }
@@ -184,6 +186,7 @@ function patchBuilderContext(context, isUsingEsbuildBuilder, buildTarget) {
184
186
  function cleanBuildTargetOptions(options) {
185
187
  delete options.buildLibsFromSource;
186
188
  delete options.customWebpackConfig;
189
+ delete options.indexHtmlTransformer;
187
190
  delete options.indexFileTransformer;
188
191
  delete options.plugins;
189
192
  return options;
@@ -4,6 +4,10 @@ export type BrowserBuilderSchema = Schema & {
4
4
  customWebpackConfig?: {
5
5
  path: string;
6
6
  };
7
- indexFileTransformer?: string;
7
+ indexHtmlTransformer?: string;
8
8
  buildLibsFromSource?: boolean;
9
+ /**
10
+ * @deprecated Use `indexHtmlTransformer` instead. It will be removed in Nx 19.
11
+ */
12
+ indexFileTransformer?: string;
9
13
  };
@@ -458,9 +458,10 @@
458
458
  "x-priority": "important",
459
459
  "additionalProperties": false
460
460
  },
461
- "indexFileTransformer": {
461
+ "indexHtmlTransformer": {
462
462
  "description": "Path to transformer function to transform the index.html",
463
- "type": "string"
463
+ "type": "string",
464
+ "alias": "indexFileTransformer"
464
465
  },
465
466
  "buildLibsFromSource": {
466
467
  "type": "boolean",
@@ -24,7 +24,7 @@ function shouldSkipInitialTargetRun(projectGraph, project, target) {
24
24
  }
25
25
  function executeWebpackBrowserBuilder(options, context) {
26
26
  options.buildLibsFromSource ??= true;
27
- const { buildLibsFromSource, customWebpackConfig, indexFileTransformer, ...delegateBuilderOptions } = options;
27
+ const { buildLibsFromSource, customWebpackConfig, indexHtmlTransformer, indexFileTransformer, ...delegateBuilderOptions } = options;
28
28
  process.env.NX_BUILD_LIBS_FROM_SOURCE = `${buildLibsFromSource}`;
29
29
  process.env.NX_BUILD_TARGET = (0, devkit_1.targetToTargetString)({ ...context.target });
30
30
  const pathToWebpackConfig = customWebpackConfig?.path &&
@@ -32,8 +32,9 @@ function executeWebpackBrowserBuilder(options, context) {
32
32
  if (pathToWebpackConfig && !(0, fs_1.existsSync)(pathToWebpackConfig)) {
33
33
  throw new Error(`Custom Webpack Config File Not Found!\nTo use a custom webpack config, please ensure the path to the custom webpack file is correct: \n${pathToWebpackConfig}`);
34
34
  }
35
- const pathToIndexFileTransformer = indexFileTransformer &&
36
- (0, devkit_1.joinPathFragments)(context.workspaceRoot, indexFileTransformer);
35
+ const normalizedIndexHtmlTransformer = indexHtmlTransformer ?? indexFileTransformer;
36
+ const pathToIndexFileTransformer = normalizedIndexHtmlTransformer &&
37
+ (0, devkit_1.joinPathFragments)(context.workspaceRoot, normalizedIndexHtmlTransformer);
37
38
  if (pathToIndexFileTransformer && !(0, fs_1.existsSync)(pathToIndexFileTransformer)) {
38
39
  throw new Error(`File containing Index File Transformer function Not Found!\n Please ensure the path to the file containing the function is correct: \n${pathToIndexFileTransformer}`);
39
40
  }
@@ -746,6 +746,25 @@ nx g &#64;nx/angular:lib ui
746
746
  <span># Add a component</span>
747
747
  nx g &#64;nx/angular:component ui/src/lib/button</pre>
748
748
  </details>
749
+ <details>
750
+ <summary>
751
+ <svg
752
+ fill="none"
753
+ stroke="currentColor"
754
+ viewBox="0 0 24 24"
755
+ xmlns="http://www.w3.org/2000/svg"
756
+ >
757
+ <path
758
+ strokeLinecap="round"
759
+ strokeLinejoin="round"
760
+ strokeWidth="2"
761
+ d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
762
+ />
763
+ </svg>
764
+ View project details
765
+ </summary>
766
+ <pre>nx show project <%= appName %> --web</pre>
767
+ </details>
749
768
  <details>
750
769
  <summary>
751
770
  <svg
@@ -749,6 +749,25 @@ nx g &#64;nx/angular:lib ui
749
749
  <span># Add a component</span>
750
750
  nx g &#64;nx/angular:component ui/src/lib/button</pre>
751
751
  </details>
752
+ <details>
753
+ <summary>
754
+ <svg
755
+ fill="none"
756
+ stroke="currentColor"
757
+ viewBox="0 0 24 24"
758
+ xmlns="http://www.w3.org/2000/svg"
759
+ >
760
+ <path
761
+ strokeLinecap="round"
762
+ strokeLinejoin="round"
763
+ strokeWidth="2"
764
+ d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
765
+ />
766
+ </svg>
767
+ View project details
768
+ </summary>
769
+ <pre>nx show project <%= appName %> --web</pre>
770
+ </details>
752
771
  <details>
753
772
  <summary>
754
773
  <svg
@@ -8,6 +8,7 @@ const application_1 = require("../application/application");
8
8
  const remote_1 = require("../remote/remote");
9
9
  const setup_mf_1 = require("../setup-mf/setup-mf");
10
10
  const lib_1 = require("./lib");
11
+ const add_mf_env_to_inputs_1 = require("../utils/add-mf-env-to-inputs");
11
12
  async function host(tree, options) {
12
13
  return await hostInternal(tree, {
13
14
  projectNameAndRootFormat: 'derived',
@@ -90,6 +91,7 @@ async function hostInternal(tree, schema) {
90
91
  typescriptConfiguration,
91
92
  });
92
93
  }
94
+ (0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(tree);
93
95
  if (!options.skipFormat) {
94
96
  await (0, devkit_1.formatFiles)(tree);
95
97
  }
@@ -8,6 +8,7 @@ const application_1 = require("../application/application");
8
8
  const setup_mf_1 = require("../setup-mf/setup-mf");
9
9
  const lib_1 = require("./lib");
10
10
  const versions_1 = require("@nx/js/src/utils/versions");
11
+ const add_mf_env_to_inputs_1 = require("../utils/add-mf-env-to-inputs");
11
12
  async function remote(tree, options) {
12
13
  return await remoteInternal(tree, {
13
14
  projectNameAndRootFormat: 'derived',
@@ -68,6 +69,7 @@ async function remoteInternal(tree, schema) {
68
69
  });
69
70
  installTasks.push(ssrInstallTask);
70
71
  }
72
+ (0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(tree);
71
73
  if (!options.skipFormat) {
72
74
  await (0, devkit_1.formatFiles)(tree);
73
75
  }
@@ -0,0 +1,2 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export declare function addMfEnvToTargetDefaultInputs(tree: Tree): void;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addMfEnvToTargetDefaultInputs = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ function addMfEnvToTargetDefaultInputs(tree) {
6
+ const nxJson = (0, devkit_1.readNxJson)(tree);
7
+ const webpackExecutor = '@nx/angular:webpack-browser';
8
+ const mfEnvVar = 'NX_MF_DEV_SERVER_STATIC_REMOTES';
9
+ nxJson.targetDefaults ??= {};
10
+ nxJson.targetDefaults[webpackExecutor] ??= {};
11
+ nxJson.targetDefaults[webpackExecutor].inputs ??= [];
12
+ let mfEnvVarExists = false;
13
+ for (const input of nxJson.targetDefaults[webpackExecutor].inputs) {
14
+ if (typeof input === 'object' && input['env'] === mfEnvVar) {
15
+ mfEnvVarExists = true;
16
+ break;
17
+ }
18
+ }
19
+ if (!mfEnvVarExists) {
20
+ nxJson.targetDefaults[webpackExecutor].inputs.push({ env: mfEnvVar });
21
+ (0, devkit_1.updateNxJson)(tree, nxJson);
22
+ }
23
+ }
24
+ exports.addMfEnvToTargetDefaultInputs = addMfEnvToTargetDefaultInputs;
@@ -0,0 +1,2 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export default function (tree: Tree): Promise<void>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ const add_mf_env_to_inputs_1 = require("../../generators/utils/add-mf-env-to-inputs");
5
+ async function default_1(tree) {
6
+ if (!isWebpackBrowserUsed(tree)) {
7
+ return;
8
+ }
9
+ (0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(tree);
10
+ await (0, devkit_1.formatFiles)(tree);
11
+ }
12
+ exports.default = default_1;
13
+ function isWebpackBrowserUsed(tree) {
14
+ const projects = (0, devkit_1.getProjects)(tree);
15
+ for (const project of projects.values()) {
16
+ const targets = project.targets;
17
+ for (const [_, target] of Object.entries(targets)) {
18
+ if (target.executor === '@nx/angular:webpack-browser' &&
19
+ (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.ts')) ||
20
+ tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.js')))) {
21
+ return true;
22
+ }
23
+ }
24
+ }
25
+ return false;
26
+ }