@nx/angular 23.1.0 → 23.1.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.
Files changed (61) hide show
  1. package/dist/src/builders/dev-server/dev-server.impl.js +21 -16
  2. package/dist/src/builders/webpack-browser/webpack-browser.impl.js +15 -12
  3. package/dist/src/builders/webpack-server/webpack-server.impl.js +8 -4
  4. package/dist/src/executors/application/application.impl.js +2 -2
  5. package/dist/src/executors/browser-esbuild/browser-esbuild.impl.js +1 -1
  6. package/dist/src/executors/extract-i18n/extract-i18n.impl.js +4 -4
  7. package/dist/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +8 -6
  8. package/dist/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +8 -8
  9. package/dist/src/executors/unit-test/unit-test.impl.js +2 -2
  10. package/dist/src/executors/utilities/builder-package.d.ts +1 -1
  11. package/dist/src/executors/utilities/builder-package.js +10 -4
  12. package/dist/src/generators/add-linting/add-linting.js +18 -7
  13. package/dist/src/generators/add-linting/schema.d.ts +4 -0
  14. package/dist/src/generators/add-linting/schema.json +8 -2
  15. package/dist/src/generators/application/lib/add-e2e.js +3 -2
  16. package/dist/src/generators/application/lib/add-linting.js +2 -1
  17. package/dist/src/generators/application/lib/create-files.js +3 -3
  18. package/dist/src/generators/application/schema.d.ts +4 -0
  19. package/dist/src/generators/application/schema.json +8 -2
  20. package/dist/src/generators/host/host.js +2 -1
  21. package/dist/src/generators/host/schema.d.ts +4 -0
  22. package/dist/src/generators/host/schema.json +8 -2
  23. package/dist/src/generators/library/lib/create-files.js +3 -0
  24. package/dist/src/generators/library/lib/normalized-schema.d.ts +4 -0
  25. package/dist/src/generators/library/library.js +4 -3
  26. package/dist/src/generators/library/schema.d.ts +4 -0
  27. package/dist/src/generators/library/schema.json +8 -2
  28. package/dist/src/generators/ng-add/migrators/projects/lib.migrator.js +1 -2
  29. package/dist/src/generators/ng-add/utilities/format-files-task.js +2 -2
  30. package/dist/src/generators/ng-add/utilities/projects.js +2 -2
  31. package/dist/src/generators/ng-add/utilities/workspace.js +3 -4
  32. package/dist/src/generators/remote/remote.js +4 -3
  33. package/dist/src/generators/remote/schema.d.ts +4 -0
  34. package/dist/src/generators/remote/schema.json +8 -2
  35. package/dist/src/generators/scam-to-standalone/lib/get-component-data-from-ast.d.ts +1 -1
  36. package/dist/src/generators/scam-to-standalone/lib/get-target-project.d.ts +1 -1
  37. package/dist/src/generators/scam-to-standalone/lib/replace-module-usages-with-component.d.ts +1 -1
  38. package/dist/src/generators/setup-mf/lib/generate-config.js +2 -1
  39. package/dist/src/generators/setup-mf/lib/setup-tspath-for-remote.js +3 -2
  40. package/dist/src/generators/setup-mf/schema.d.ts +4 -0
  41. package/dist/src/generators/setup-mf/schema.json +8 -2
  42. package/dist/src/generators/setup-mf/setup-mf.js +2 -0
  43. package/dist/src/generators/setup-ssr/lib/add-dependencies.d.ts +1 -1
  44. package/dist/src/generators/setup-ssr/lib/add-dependencies.js +6 -1
  45. package/dist/src/generators/setup-ssr/lib/normalize-options.js +15 -3
  46. package/dist/src/generators/setup-ssr/lib/update-project-config.js +1 -1
  47. package/dist/src/generators/setup-ssr/schema.d.ts +2 -0
  48. package/dist/src/generators/setup-ssr/setup-ssr.js +1 -1
  49. package/dist/src/generators/utils/add-vitest.js +1 -2
  50. package/dist/src/generators/utils/tsconfig-utils.js +2 -7
  51. package/dist/src/migrations/update-20-2-0/migrate-mf-imports-to-new-package.js +2 -3
  52. package/dist/src/migrations/update-21-0-0/change-data-persistence-operators-imports-to-ngrx-router-store-data-persistence.js +3 -4
  53. package/dist/src/migrations/update-23-1-0/add-angular-build.md +1 -1
  54. package/dist/src/migrations/update-23-1-0/add-optional-webpack-packages.d.ts +2 -0
  55. package/dist/src/migrations/update-23-1-0/add-optional-webpack-packages.js +101 -0
  56. package/dist/src/migrations/update-23-1-0/add-optional-webpack-packages.md +39 -0
  57. package/dist/src/plugins/plugin.js +2 -4
  58. package/dist/tailwind.d.ts +1 -1
  59. package/dist/tailwind.js +2 -2
  60. package/migrations.json +6 -0
  61. package/package.json +32 -13
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = addOptionalWebpackPackages;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const internal_1 = require("@nx/devkit/internal");
6
+ const versions_1 = require("../../utils/versions");
7
+ const webpackExecutors = new Set([
8
+ '@nx/angular:webpack-browser',
9
+ '@nx/angular:webpack-server',
10
+ ]);
11
+ const webpackBuildTargetExecutors = new Set([
12
+ '@nx/angular:webpack-browser',
13
+ '@angular-devkit/build-angular:browser',
14
+ ]);
15
+ const moduleFederationExecutors = new Set([
16
+ '@nx/angular:module-federation-dev-server',
17
+ '@nx/angular:module-federation-dev-ssr',
18
+ ]);
19
+ function resolveBuildTargetExecutor(targetString, projects, targetDefaults) {
20
+ const [projectName, targetName] = targetString.split(':');
21
+ const target = targetName
22
+ ? projects.get(projectName)?.targets?.[targetName]
23
+ : undefined;
24
+ if (target === undefined) {
25
+ return undefined;
26
+ }
27
+ // The referenced build target can inherit its executor from targetDefaults,
28
+ // which the raw project config does not merge, so resolve it before matching.
29
+ return (target.executor ??
30
+ (0, internal_1.readTargetDefaultsForTarget)(targetName, targetDefaults)?.executor);
31
+ }
32
+ function usesWebpackDevServer(target, projects, targetDefaults) {
33
+ if (target.executor !== '@nx/angular:dev-server') {
34
+ return false;
35
+ }
36
+ return [target.options, ...Object.values(target.configurations ?? {})].some((options) => {
37
+ const buildTarget = options?.buildTarget ?? options?.browserTarget;
38
+ if (typeof buildTarget !== 'string') {
39
+ return false;
40
+ }
41
+ const executor = resolveBuildTargetExecutor(buildTarget, projects, targetDefaults);
42
+ return (executor !== undefined && webpackBuildTargetExecutors.has(executor));
43
+ });
44
+ }
45
+ async function addOptionalWebpackPackages(tree) {
46
+ const projects = (0, devkit_1.getProjects)(tree);
47
+ const nxJson = (0, devkit_1.readNxJson)(tree);
48
+ const targetDefaults = nxJson?.targetDefaults;
49
+ let needsWebpack = false;
50
+ let needsModuleFederation = false;
51
+ let needsRspack = false;
52
+ for (const [, project] of projects) {
53
+ for (const target of Object.values(project.targets ?? {})) {
54
+ needsWebpack ||=
55
+ webpackExecutors.has(target.executor) ||
56
+ usesWebpackDevServer(target, projects, targetDefaults);
57
+ needsModuleFederation ||= moduleFederationExecutors.has(target.executor);
58
+ needsRspack ||= target.executor?.startsWith('@nx/rspack:') ?? false;
59
+ }
60
+ // Remotes get a plain dev-server (no Module Federation executor) but still
61
+ // generate a module-federation.config that requires @nx/module-federation
62
+ // at build time, so detect them by that config file too. This covers
63
+ // remotes whose host lives in a different workspace.
64
+ needsModuleFederation ||=
65
+ tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.ts')) ||
66
+ tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.js'));
67
+ }
68
+ // targetDefaults are keyed by target name or executor, and a default can set
69
+ // an executor that an empty project target inherits, so scan the keys and any
70
+ // executor on the default (both the object and array forms).
71
+ for (const [targetOrExecutor, config] of Object.entries(targetDefaults ?? {})) {
72
+ const executors = [targetOrExecutor];
73
+ for (const entry of Array.isArray(config) ? config : [config]) {
74
+ if (entry.executor != null) {
75
+ executors.push(entry.executor);
76
+ }
77
+ }
78
+ for (const executor of executors) {
79
+ needsWebpack ||= webpackExecutors.has(executor);
80
+ needsModuleFederation ||= moduleFederationExecutors.has(executor);
81
+ needsRspack ||= executor.startsWith('@nx/rspack:');
82
+ }
83
+ }
84
+ needsRspack ||=
85
+ nxJson?.plugins?.some((plugin) => typeof plugin === 'string'
86
+ ? plugin === '@nx/rspack/plugin'
87
+ : plugin.plugin === '@nx/rspack/plugin') ?? false;
88
+ if (!needsWebpack && !needsModuleFederation && !needsRspack) {
89
+ return;
90
+ }
91
+ return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
92
+ ...(needsWebpack
93
+ ? {
94
+ '@nx/webpack': versions_1.nxVersion,
95
+ 'webpack-merge': versions_1.webpackMergeVersion,
96
+ }
97
+ : {}),
98
+ ...(needsModuleFederation ? { '@nx/module-federation': versions_1.nxVersion } : {}),
99
+ ...(needsRspack ? { '@nx/rspack': versions_1.nxVersion } : {}),
100
+ }, undefined, true);
101
+ }
@@ -0,0 +1,39 @@
1
+ #### Add Optional Webpack Packages
2
+
3
+ Adds `@nx/webpack`, `@nx/module-federation`, `@nx/rspack`, and `webpack-merge` to the workspace when existing targets require them.
4
+
5
+ These packages are no longer direct dependencies of `@nx/angular`; they are now optional peer dependencies, so installing `@nx/angular` no longer pulls webpack tooling into workspaces that only use the esbuild or Vite build stack. This migration backfills them for workspaces that already use webpack, Module Federation, or Rspack so those builds keep working after upgrading. Packages that are already present are left untouched.
6
+
7
+ A package is added only when a matching target exists:
8
+
9
+ - `@nx/webpack` and `webpack-merge`: an `@nx/angular:webpack-browser` or `@nx/angular:webpack-server` target, or an `@nx/angular:dev-server` whose build target uses `@nx/angular:webpack-browser` or `@angular-devkit/build-angular:browser`.
10
+ - `@nx/module-federation`: an `@nx/angular:module-federation-dev-server` or `@nx/angular:module-federation-dev-ssr` target, or a project with a `module-federation.config.{js,ts}` file (covers remotes whose host lives in another workspace).
11
+ - `@nx/rspack`: an `@nx/rspack:*` target or the `@nx/rspack/plugin` plugin in `nx.json`.
12
+
13
+ Targets that inherit their executor from an `nx.json` `targetDefaults` entry are detected too.
14
+
15
+ #### Examples
16
+
17
+ For a workspace with an `@nx/angular:webpack-browser` build target, the migration adds the webpack packages to `devDependencies`.
18
+
19
+ ##### Before
20
+
21
+ ```jsonc title="package.json"
22
+ {
23
+ "devDependencies": {
24
+ "@nx/angular": "23.1.0",
25
+ },
26
+ }
27
+ ```
28
+
29
+ ##### After
30
+
31
+ ```jsonc title="package.json"
32
+ {
33
+ "devDependencies": {
34
+ "@nx/angular": "23.1.0",
35
+ "@nx/webpack": "23.1.0",
36
+ "webpack-merge": "^5.8.0",
37
+ },
38
+ }
39
+ ```
@@ -8,8 +8,6 @@ const js_1 = require("@nx/js");
8
8
  const node_fs_1 = require("node:fs");
9
9
  const node_path_1 = require("node:path");
10
10
  const posix = tslib_1.__importStar(require("node:path/posix"));
11
- const devkit_internals_1 = require("nx/src/devkit-internals");
12
- const cache_directory_1 = require("nx/src/utils/cache-directory");
13
11
  const targets_1 = require("../utils/targets");
14
12
  const vitest_1 = require("./utils/vitest");
15
13
  const knownExecutors = {
@@ -48,8 +46,8 @@ const knownExecutors = {
48
46
  exports.createNodes = [
49
47
  '**/angular.json',
50
48
  async (configFiles, options, context) => {
51
- const optionsHash = (0, devkit_internals_1.hashObject)(options);
52
- const cachePath = (0, node_path_1.join)(cache_directory_1.workspaceDataDirectory, `angular-${optionsHash}.hash`);
49
+ const optionsHash = (0, internal_1.hashObject)(options);
50
+ const cachePath = (0, node_path_1.join)(internal_1.workspaceDataDirectory, `angular-${optionsHash}.hash`);
53
51
  const projectsCache = new internal_1.PluginCache(cachePath);
54
52
  const packageManager = (0, devkit_1.detectPackageManager)(context.workspaceRoot);
55
53
  const pmc = (0, devkit_1.getPackageManagerCommand)(packageManager);
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * @deprecated `@nx/angular/tailwind` will be removed in Nx 24. Migrate to Tailwind CSS v4 which no longer needs glob patterns.
3
- * See: https://nx.dev/docs/technologies/angular/guides/using-tailwind-css-with-angular
3
+ * See: https://nx.dev/docs/technologies/angular/guides/using-tailwind-css-with-angular-projects
4
4
  */
5
5
  export declare function createGlobPatternsForDependencies(dirPath: string, fileGlobPattern?: string): string[];
package/dist/tailwind.js CHANGED
@@ -5,14 +5,14 @@ const internal_1 = require("@nx/js/internal");
5
5
  let hasWarned = false;
6
6
  /**
7
7
  * @deprecated `@nx/angular/tailwind` will be removed in Nx 24. Migrate to Tailwind CSS v4 which no longer needs glob patterns.
8
- * See: https://nx.dev/docs/technologies/angular/guides/using-tailwind-css-with-angular
8
+ * See: https://nx.dev/docs/technologies/angular/guides/using-tailwind-css-with-angular-projects
9
9
  */
10
10
  function createGlobPatternsForDependencies(dirPath, fileGlobPattern = '/**/!(*.stories|*.spec).{ts,html}') {
11
11
  if (!hasWarned) {
12
12
  hasWarned = true;
13
13
  console.warn(`\nWARNING: "@nx/angular/tailwind" is deprecated and will be removed in Nx 24.\n` +
14
14
  `Migrate to Tailwind CSS v4 which no longer needs glob patterns for content detection.\n` +
15
- `See: https://nx.dev/docs/technologies/angular/guides/using-tailwind-css-with-angular\n`);
15
+ `See: https://nx.dev/docs/technologies/angular/guides/using-tailwind-css-with-angular-projects\n`);
16
16
  }
17
17
  try {
18
18
  return (0, internal_1.createGlobPatternsForDependencies)(dirPath, fileGlobPattern);
package/migrations.json CHANGED
@@ -366,6 +366,12 @@
366
366
  "description": "Remove the `extendedDiagnostics` Angular compiler option from tsconfig files where `strictTemplates` resolves to `false`. Angular v22's `strict-templates-default` and `strict-safe-navigation-narrow` migrations can together produce this combination, which the Angular compiler rejects (`extendedDiagnostics` requires `strictTemplates` to be enabled).",
367
367
  "factory": "./dist/src/migrations/update-23-1-0/remove-conflicting-extended-diagnostics",
368
368
  "documentation": "./dist/src/migrations/update-23-1-0/remove-conflicting-extended-diagnostics.md"
369
+ },
370
+ "update-23-1-0-add-optional-webpack-packages": {
371
+ "version": "23.1.0-rc.3",
372
+ "description": "Add optional webpack, Module Federation, and Rspack packages when existing targets require them.",
373
+ "factory": "./dist/src/migrations/update-23-1-0/add-optional-webpack-packages",
374
+ "documentation": "./dist/src/migrations/update-23-1-0/add-optional-webpack-packages.md"
369
375
  }
370
376
  },
371
377
  "packageJsonUpdates": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/angular",
3
- "version": "23.1.0",
3
+ "version": "23.1.2",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "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, Playwright 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- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
@@ -80,19 +80,14 @@
80
80
  "picomatch": "4.0.4",
81
81
  "semver": "^7.6.3",
82
82
  "tslib": "^2.3.0",
83
- "webpack-merge": "^5.8.0",
84
- "@nx/devkit": "23.1.0",
85
- "@nx/module-federation": "23.1.0",
86
- "@nx/rspack": "23.1.0",
87
- "@nx/web": "23.1.0",
88
- "@nx/js": "23.1.0",
89
- "@nx/eslint": "23.1.0",
90
- "@nx/webpack": "23.1.0"
83
+ "@nx/devkit": "23.1.2",
84
+ "@nx/js": "23.1.2",
85
+ "@nx/eslint": "23.1.2",
86
+ "@nx/web": "23.1.2"
91
87
  },
92
88
  "devDependencies": {
93
- "@nx/cypress": "23.1.0",
94
- "@nx/vitest": "23.1.0",
95
- "nx": "23.1.0"
89
+ "@nx/vitest": "23.1.2",
90
+ "nx": "23.1.2"
96
91
  },
97
92
  "peerDependencies": {
98
93
  "@angular/build": ">= 20.0.0 < 23.0.0",
@@ -101,7 +96,13 @@
101
96
  "@angular-devkit/schematics": ">= 20.0.0 < 23.0.0",
102
97
  "@schematics/angular": ">= 20.0.0 < 23.0.0",
103
98
  "ng-packagr": ">= 20.0.0 < 23.0.0",
104
- "rxjs": "^6.5.3 || ^7.5.0"
99
+ "rxjs": "^6.5.3 || ^7.5.0",
100
+ "webpack-merge": "^5.8.0",
101
+ "@nx/cypress": "23.1.2",
102
+ "@nx/module-federation": "23.1.2",
103
+ "@nx/playwright": "23.1.2",
104
+ "@nx/webpack": "23.1.2",
105
+ "@nx/rspack": "23.1.2"
105
106
  },
106
107
  "peerDependenciesMeta": {
107
108
  "@angular/build": {
@@ -110,8 +111,26 @@
110
111
  "@angular-devkit/build-angular": {
111
112
  "optional": true
112
113
  },
114
+ "@nx/cypress": {
115
+ "optional": true
116
+ },
117
+ "@nx/module-federation": {
118
+ "optional": true
119
+ },
120
+ "@nx/playwright": {
121
+ "optional": true
122
+ },
123
+ "@nx/rspack": {
124
+ "optional": true
125
+ },
126
+ "@nx/webpack": {
127
+ "optional": true
128
+ },
113
129
  "ng-packagr": {
114
130
  "optional": true
131
+ },
132
+ "webpack-merge": {
133
+ "optional": true
115
134
  }
116
135
  },
117
136
  "publishConfig": {