@nx/angular 23.1.0-beta.4 → 23.1.0-beta.5

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.
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addE2e = addE2e;
4
+ const internal_1 = require("@nx/devkit/internal");
4
5
  const devkit_1 = require("@nx/devkit");
5
6
  const versions_1 = require("../../../utils/versions");
6
7
  async function addE2e(tree, options) {
@@ -65,12 +66,9 @@ async function addE2e(tree, options) {
65
66
  function getAngularE2EWebServerInfo(tree, projectName, portOverride) {
66
67
  const nxJson = (0, devkit_1.readNxJson)(tree);
67
68
  let e2ePort = portOverride ?? 4200;
68
- if (nxJson.targetDefaults?.['serve'] &&
69
- (nxJson.targetDefaults?.['serve'].options?.port ||
70
- nxJson.targetDefaults?.['serve'].options?.env?.PORT)) {
71
- e2ePort =
72
- nxJson.targetDefaults?.['serve'].options?.port ||
73
- nxJson.targetDefaults?.['serve'].options?.env?.PORT;
69
+ const serveTargetOptions = (0, internal_1.readTargetDefaultsForTarget)('serve', nxJson.targetDefaults)?.options;
70
+ if (serveTargetOptions?.port || serveTargetOptions?.env?.PORT) {
71
+ e2ePort = serveTargetOptions.port || serveTargetOptions.env.PORT;
74
72
  }
75
73
  const pm = (0, devkit_1.getPackageManagerCommand)();
76
74
  return {
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Migrator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const internal_1 = require("@nx/devkit/internal");
5
6
  const path_1 = require("path");
6
7
  class Migrator {
7
8
  constructor(tree, projectConfig, logger) {
@@ -66,11 +67,15 @@ class Migrator {
66
67
  if (!targetNames.length) {
67
68
  return;
68
69
  }
69
- const nxJson = (0, devkit_1.readNxJson)(this.tree);
70
- nxJson.targetDefaults ??= {};
71
- for (const target of targetNames) {
72
- nxJson.targetDefaults[target] ??= {};
73
- nxJson.targetDefaults[target].cache ??= true;
70
+ const nxJson = (0, devkit_1.readNxJson)(this.tree) ?? {};
71
+ for (const name of targetNames) {
72
+ const existing = (0, internal_1.findTargetDefault)(nxJson.targetDefaults, {
73
+ target: name,
74
+ });
75
+ (0, internal_1.upsertTargetDefault)(this.tree, nxJson, {
76
+ target: name,
77
+ cache: existing?.cache ?? true,
78
+ });
74
79
  }
75
80
  (0, devkit_1.updateNxJson)(this.tree, nxJson);
76
81
  }
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateProjectConfigForApplicationBuilder = updateProjectConfigForApplicationBuilder;
4
4
  exports.updateProjectConfigForBrowserBuilder = updateProjectConfigForBrowserBuilder;
5
5
  const devkit_1 = require("@nx/devkit");
6
- const internal_1 = require("@nx/js/internal");
6
+ const internal_1 = require("@nx/devkit/internal");
7
+ const internal_2 = require("@nx/js/internal");
7
8
  const constants_1 = require("./constants");
8
9
  function updateProjectConfigForApplicationBuilder(tree, options) {
9
10
  const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
@@ -28,7 +29,7 @@ function updateProjectConfigForApplicationBuilder(tree, options) {
28
29
  }
29
30
  }
30
31
  }
31
- const sourceRoot = (0, internal_1.getProjectSourceRoot)(project, tree);
32
+ const sourceRoot = (0, internal_2.getProjectSourceRoot)(project, tree);
32
33
  buildTarget.options ??= {};
33
34
  buildTarget.options.outputPath = outputPath;
34
35
  buildTarget.options.server = (0, devkit_1.joinPathFragments)(sourceRoot, options.main);
@@ -50,7 +51,7 @@ function updateProjectConfigForBrowserBuilder(tree, options) {
50
51
  configurations[key] = getServerOptions(options);
51
52
  }
52
53
  }
53
- const sourceRoot = (0, internal_1.getProjectSourceRoot)(projectConfig, tree);
54
+ const sourceRoot = (0, internal_2.getProjectSourceRoot)(projectConfig, tree);
54
55
  projectConfig.targets.server = {
55
56
  dependsOn: ['build'],
56
57
  executor: buildTarget.executor.startsWith('@angular-devkit/build-angular:')
@@ -98,14 +99,17 @@ function updateProjectConfigForBrowserBuilder(tree, options) {
98
99
  defaultConfiguration: 'production',
99
100
  };
100
101
  (0, devkit_1.updateProjectConfiguration)(tree, options.project, projectConfig);
101
- const nxJson = (0, devkit_1.readNxJson)(tree);
102
+ const nxJson = (0, devkit_1.readNxJson)(tree) ?? {};
102
103
  if (nxJson.tasksRunnerOptions?.default?.options?.cacheableOperations &&
103
104
  !nxJson.tasksRunnerOptions.default.options.cacheableOperations.includes('server')) {
104
105
  nxJson.tasksRunnerOptions.default.options.cacheableOperations.push('server');
105
106
  }
106
- nxJson.targetDefaults ??= {};
107
- nxJson.targetDefaults.server ??= {};
108
- nxJson.targetDefaults.server.cache ??= true;
107
+ const existing = (0, internal_1.findTargetDefault)(nxJson.targetDefaults, {
108
+ target: 'server',
109
+ });
110
+ if (!existing || existing.cache === undefined) {
111
+ (0, internal_1.upsertTargetDefault)(tree, nxJson, { target: 'server', cache: true });
112
+ }
109
113
  (0, devkit_1.updateNxJson)(tree, nxJson);
110
114
  }
111
115
  function getServerOptions(options = {}) {
@@ -2,29 +2,35 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addMfEnvToTargetDefaultInputs = addMfEnvToTargetDefaultInputs;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const internal_1 = require("@nx/devkit/internal");
5
6
  function addMfEnvToTargetDefaultInputs(tree) {
6
- const nxJson = (0, devkit_1.readNxJson)(tree);
7
+ const nxJson = (0, devkit_1.readNxJson)(tree) ?? {};
7
8
  const webpackExecutor = '@nx/angular:webpack-browser';
8
9
  const mfEnvVar = 'NX_MF_DEV_REMOTES';
9
- const inputs = [
10
+ const defaultInputs = [
10
11
  ...(nxJson.namedInputs && 'production' in nxJson.namedInputs
11
12
  ? ['production', '^production']
12
13
  : ['default', '^default']),
13
14
  ];
14
- nxJson.targetDefaults ??= {};
15
- nxJson.targetDefaults[webpackExecutor] ??= {};
16
- nxJson.targetDefaults[webpackExecutor].inputs ??= inputs;
17
- nxJson.targetDefaults[webpackExecutor].dependsOn ??= ['^build'];
15
+ const existing = (0, internal_1.findTargetDefault)(nxJson.targetDefaults, {
16
+ executor: webpackExecutor,
17
+ });
18
+ const inputs = [...(existing?.inputs ?? defaultInputs)];
18
19
  let mfEnvVarExists = false;
19
- for (const input of nxJson.targetDefaults[webpackExecutor].inputs) {
20
+ for (const input of inputs) {
20
21
  if (typeof input === 'object' && input['env'] === mfEnvVar) {
21
22
  mfEnvVarExists = true;
22
23
  break;
23
24
  }
24
25
  }
25
26
  if (!mfEnvVarExists) {
26
- nxJson.targetDefaults[webpackExecutor].inputs.push({ env: mfEnvVar });
27
+ inputs.push({ env: mfEnvVar });
27
28
  }
28
- nxJson.targetDefaults[webpackExecutor].cache = true;
29
+ (0, internal_1.upsertTargetDefault)(tree, nxJson, {
30
+ executor: webpackExecutor,
31
+ cache: true,
32
+ inputs,
33
+ dependsOn: existing?.dependsOn ?? ['^build'],
34
+ });
29
35
  (0, devkit_1.updateNxJson)(tree, nxJson);
30
36
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addVitestAngular = addVitestAngular;
4
4
  exports.addVitestAnalog = addVitestAnalog;
5
5
  const devkit_1 = require("@nx/devkit");
6
+ const internal_1 = require("@nx/devkit/internal");
6
7
  const devkit_internals_1 = require("nx/src/devkit-internals");
7
8
  const semver_1 = require("semver");
8
9
  const versions_1 = require("../../utils/versions");
@@ -16,15 +17,18 @@ async function addVitestAngular(tree, options) {
16
17
  project.targets ??= {};
17
18
  project.targets.test = { executor, options: { watch: false } };
18
19
  (0, devkit_1.updateProjectConfiguration)(tree, options.name, project);
19
- const nxJson = (0, devkit_1.readNxJson)(tree);
20
- nxJson.targetDefaults ??= {};
21
- nxJson.targetDefaults[executor] ??= {
22
- cache: true,
23
- inputs: nxJson.namedInputs && 'production' in nxJson.namedInputs
24
- ? ['default', '^production']
25
- : ['default', '^default'],
26
- };
27
- (0, devkit_1.updateNxJson)(tree, nxJson);
20
+ const nxJson = (0, devkit_1.readNxJson)(tree) ?? {};
21
+ const existing = (0, internal_1.findTargetDefault)(nxJson.targetDefaults, { executor });
22
+ if (!existing) {
23
+ (0, internal_1.upsertTargetDefault)(tree, nxJson, {
24
+ executor,
25
+ cache: true,
26
+ inputs: nxJson.namedInputs && 'production' in nxJson.namedInputs
27
+ ? ['default', '^production']
28
+ : ['default', '^default'],
29
+ });
30
+ (0, devkit_1.updateNxJson)(tree, nxJson);
31
+ }
28
32
  configureTypeScriptForVitest(tree, options.projectRoot);
29
33
  addVitestScreenshotsToGitIgnore(tree);
30
34
  if (options.skipPackageJson) {
@@ -5,7 +5,7 @@ const devkit_1 = require("@nx/devkit");
5
5
  const internal_1 = require("@nx/devkit/internal");
6
6
  async function default_1(tree) {
7
7
  let usesModuleFederation = false;
8
- (0, internal_1.forEachExecutorOptions)(tree, '@nx/angular:webpack-browser', (options, projectName, targetName) => {
8
+ (0, internal_1.forEachExecutorOptions)(tree, '@nx/angular:webpack-browser', (options) => {
9
9
  const webpackConfig = options.webpackConfig;
10
10
  if (!webpackConfig) {
11
11
  return;
@@ -18,34 +18,40 @@ async function default_1(tree) {
18
18
  if (!usesModuleFederation) {
19
19
  return;
20
20
  }
21
- const nxJson = (0, devkit_1.readNxJson)(tree);
21
+ const nxJson = (0, devkit_1.readNxJson)(tree) ?? {};
22
22
  const nxMFDevRemotesEnvVar = 'NX_MF_DEV_REMOTES';
23
- const inputs = [
23
+ const webpackExecutor = '@nx/angular:webpack-browser';
24
+ const defaultInputs = [
24
25
  ...(nxJson.namedInputs && 'production' in nxJson.namedInputs
25
26
  ? ['production', '^production']
26
27
  : ['default', '^default']),
27
28
  { env: nxMFDevRemotesEnvVar },
28
29
  ];
29
- if (!nxJson.targetDefaults ||
30
- !nxJson.targetDefaults?.['@nx/angular:webpack-browser']) {
31
- nxJson.targetDefaults ??= {};
32
- nxJson.targetDefaults['@nx/angular:webpack-browser'] = {
30
+ const existing = (0, internal_1.findTargetDefault)(nxJson.targetDefaults, {
31
+ executor: webpackExecutor,
32
+ });
33
+ if (!existing) {
34
+ (0, internal_1.upsertTargetDefault)(tree, nxJson, {
35
+ executor: webpackExecutor,
33
36
  cache: true,
34
- inputs,
37
+ inputs: defaultInputs,
35
38
  dependsOn: ['^build'],
36
- };
39
+ });
37
40
  }
38
41
  else {
39
- nxJson.targetDefaults['@nx/angular:webpack-browser'].dependsOn ??= [];
40
- if (!nxJson.targetDefaults['@nx/angular:webpack-browser'].dependsOn.includes('^build')) {
41
- nxJson.targetDefaults['@nx/angular:webpack-browser'].dependsOn.push('^build');
42
- }
43
- nxJson.targetDefaults['@nx/angular:webpack-browser'].inputs ??= [];
44
- if (!nxJson.targetDefaults['@nx/angular:webpack-browser'].inputs.find((i) => typeof i === 'string' ? false : i['env'] === nxMFDevRemotesEnvVar)) {
45
- nxJson.targetDefaults['@nx/angular:webpack-browser'].inputs.push({
46
- env: nxMFDevRemotesEnvVar,
47
- });
42
+ const dependsOn = [...(existing.dependsOn ?? [])];
43
+ if (!dependsOn.includes('^build'))
44
+ dependsOn.push('^build');
45
+ const inputs = [...(existing.inputs ?? [])];
46
+ if (!inputs.find((i) => typeof i === 'string' ? false : i['env'] === nxMFDevRemotesEnvVar)) {
47
+ inputs.push({ env: nxMFDevRemotesEnvVar });
48
48
  }
49
+ (0, internal_1.upsertTargetDefault)(tree, nxJson, {
50
+ executor: webpackExecutor,
51
+ ...(existing.cache !== undefined ? { cache: existing.cache } : {}),
52
+ inputs,
53
+ dependsOn,
54
+ });
49
55
  }
50
56
  (0, devkit_1.updateNxJson)(tree, nxJson);
51
57
  await (0, devkit_1.formatFiles)(tree);
@@ -39,11 +39,7 @@ async function default_1(tree) {
39
39
  if (!nxJson.targetDefaults) {
40
40
  return;
41
41
  }
42
- for (const [targetOrExecutor, targetConfig] of Object.entries(nxJson.targetDefaults)) {
43
- if (!exports.executors.includes(targetOrExecutor) &&
44
- !exports.executors.includes(targetConfig.executor)) {
45
- continue;
46
- }
42
+ const cleanEntry = (targetConfig) => {
47
43
  if (targetConfig.options) {
48
44
  delete targetConfig.options.tailwindConfig;
49
45
  if (!Object.keys(targetConfig.options).length) {
@@ -59,9 +55,23 @@ async function default_1(tree) {
59
55
  if (!Object.keys(targetConfig.configurations ?? {}).length) {
60
56
  delete targetConfig.configurations;
61
57
  }
62
- if (!Object.keys(targetConfig).length ||
63
- (Object.keys(targetConfig).length === 1 &&
64
- Object.keys(targetConfig)[0] === 'executor')) {
58
+ return {
59
+ empty: !Object.keys(targetConfig).length ||
60
+ (Object.keys(targetConfig).length === 1 &&
61
+ Object.keys(targetConfig)[0] === 'executor'),
62
+ };
63
+ };
64
+ for (const [targetOrExecutor, targetConfig] of Object.entries(nxJson.targetDefaults)) {
65
+ if (Array.isArray(targetConfig)) {
66
+ // This migration predates the filtered array value form; values are plain objects here.
67
+ continue;
68
+ }
69
+ if (!exports.executors.includes(targetOrExecutor) &&
70
+ !exports.executors.includes(targetConfig.executor)) {
71
+ continue;
72
+ }
73
+ const { empty } = cleanEntry(targetConfig);
74
+ if (empty) {
65
75
  delete nxJson.targetDefaults[targetOrExecutor];
66
76
  }
67
77
  if (!Object.keys(nxJson.targetDefaults).length) {
@@ -41,12 +41,16 @@ async function default_1(tree) {
41
41
  break;
42
42
  }
43
43
  }
44
- // nx.json targetDefaults: a project's empty `test` target can inherit a Karma
45
- // executor/runner from a default.
44
+ // nx.json targetDefaults (keyed by target name or executor): a project's empty
45
+ // `test` target can inherit a Karma executor/runner from a default.
46
46
  if (!needsInstrumenter) {
47
47
  const targetDefaults = (0, devkit_1.readNxJson)(tree)?.targetDefaults;
48
48
  if (targetDefaults) {
49
- needsInstrumenter = Object.entries(targetDefaults).some(([targetOrExecutor, config]) => usesKarma([targetOrExecutor, config.executor], config));
49
+ needsInstrumenter = Object.entries(targetDefaults).some(([targetOrExecutor, config]) =>
50
+ // This migration predates the filtered array value form; values are
51
+ // plain objects here.
52
+ !Array.isArray(config) &&
53
+ usesKarma([targetOrExecutor, config.executor], config));
50
54
  }
51
55
  }
52
56
  if (!needsInstrumenter) {
@@ -49,11 +49,16 @@ async function default_1(tree) {
49
49
  (0, devkit_1.updateProjectConfiguration)(tree, projectName, project);
50
50
  }
51
51
  }
52
- // nx.json targetDefaults
52
+ // nx.json targetDefaults (keyed by target name or executor)
53
53
  const nxJson = (0, devkit_1.readNxJson)(tree);
54
54
  if (nxJson?.targetDefaults) {
55
55
  let isUpdated = false;
56
56
  for (const [targetOrExecutor, targetConfig] of Object.entries(nxJson.targetDefaults)) {
57
+ // This migration predates the filtered array value form; values are
58
+ // plain objects here.
59
+ if (Array.isArray(targetConfig)) {
60
+ continue;
61
+ }
57
62
  if (!ssrApplicationExecutors.includes(targetOrExecutor) &&
58
63
  !ssrApplicationExecutors.includes(targetConfig.executor)) {
59
64
  continue;
@@ -48,12 +48,11 @@ After:
48
48
 
49
49
  Before:
50
50
 
51
- ```jsonc {9}
51
+ ```jsonc {8}
52
52
  // nx.json
53
53
  {
54
- "targetDefaults": [
55
- {
56
- "executor": "@nx/angular:application",
54
+ "targetDefaults": {
55
+ "@nx/angular:application": {
57
56
  "options": {
58
57
  "ssr": {
59
58
  "entry": "src/server.ts",
@@ -61,18 +60,17 @@ Before:
61
60
  },
62
61
  },
63
62
  },
64
- ],
63
+ },
65
64
  }
66
65
  ```
67
66
 
68
67
  After:
69
68
 
70
- ```jsonc {9}
69
+ ```jsonc {8}
71
70
  // nx.json
72
71
  {
73
- "targetDefaults": [
74
- {
75
- "executor": "@nx/angular:application",
72
+ "targetDefaults": {
73
+ "@nx/angular:application": {
76
74
  "options": {
77
75
  "ssr": {
78
76
  "entry": "src/server.ts",
@@ -80,6 +78,6 @@ After:
80
78
  },
81
79
  },
82
80
  },
83
- ],
81
+ },
84
82
  }
85
83
  ```
@@ -1,6 +1,6 @@
1
1
  export declare const nxVersion: any;
2
- export declare const angularVersion = "~22.0.0";
3
- export declare const angularDevkitVersion = "~22.0.0";
2
+ export declare const angularVersion = "~22.0.4";
3
+ export declare const angularDevkitVersion = "~22.0.4";
4
4
  export declare const ngPackagrVersion = "~22.0.0";
5
5
  export declare const ngrxVersion = "^21.0.0";
6
6
  export declare const rxjsVersion = "~7.8.0";
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.jsoncEslintParserVersion = exports.oxcProjectRuntimeVersion = exports.jsdomVersion = exports.vitestVersion = exports.jasmineMarblesVersion = exports.typesNodeVersion = exports.jestPresetAngularVersion = exports.lessVersion = exports.tsNodeVersion = exports.autoprefixerVersion = exports.postcssUrlVersion = exports.postcssVersion = exports.typescriptEslintVersion = exports.angularEslintVersion = exports.webpackMergeVersion = exports.moduleFederationEnhancedVersion = exports.moduleFederationNodeVersion = exports.browserSyncVersion = exports.typesExpressVersion = exports.expressVersion = exports.typesCorsVersion = exports.corsVersion = exports.tsLibVersion = exports.zoneJsVersion = exports.rxjsVersion = exports.ngrxVersion = exports.ngPackagrVersion = exports.angularDevkitVersion = exports.angularVersion = exports.nxVersion = void 0;
4
4
  const path_1 = require("path");
5
5
  exports.nxVersion = require((0, path_1.join)('@nx/angular', 'package.json')).version;
6
- exports.angularVersion = '~22.0.0';
7
- exports.angularDevkitVersion = '~22.0.0';
6
+ exports.angularVersion = '~22.0.4';
7
+ exports.angularDevkitVersion = '~22.0.4';
8
8
  exports.ngPackagrVersion = '~22.0.0';
9
9
  exports.ngrxVersion = '^21.0.0';
10
10
  exports.rxjsVersion = '~7.8.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/angular",
3
- "version": "23.1.0-beta.4",
3
+ "version": "23.1.0-beta.5",
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,18 +80,18 @@
80
80
  "semver": "^7.6.3",
81
81
  "tslib": "^2.3.0",
82
82
  "webpack-merge": "^5.8.0",
83
- "@nx/devkit": "23.1.0-beta.4",
84
- "@nx/eslint": "23.1.0-beta.4",
85
- "@nx/module-federation": "23.1.0-beta.4",
86
- "@nx/rspack": "23.1.0-beta.4",
87
- "@nx/js": "23.1.0-beta.4",
88
- "@nx/web": "23.1.0-beta.4",
89
- "@nx/webpack": "23.1.0-beta.4"
83
+ "@nx/devkit": "23.1.0-beta.5",
84
+ "@nx/eslint": "23.1.0-beta.5",
85
+ "@nx/module-federation": "23.1.0-beta.5",
86
+ "@nx/rspack": "23.1.0-beta.5",
87
+ "@nx/web": "23.1.0-beta.5",
88
+ "@nx/webpack": "23.1.0-beta.5",
89
+ "@nx/js": "23.1.0-beta.5"
90
90
  },
91
91
  "devDependencies": {
92
- "@nx/cypress": "23.1.0-beta.4",
93
- "nx": "23.1.0-beta.4",
94
- "@nx/vitest": "23.1.0-beta.4"
92
+ "@nx/cypress": "23.1.0-beta.5",
93
+ "@nx/vitest": "23.1.0-beta.5",
94
+ "nx": "23.1.0-beta.5"
95
95
  },
96
96
  "peerDependencies": {
97
97
  "@angular/build": ">= 20.0.0 < 23.0.0",