@nx/angular 21.3.0-canary.20250710-13551c9 → 21.3.0-canary.20250712-18e5d95

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 (39) hide show
  1. package/migrations.json +74 -0
  2. package/package.json +9 -9
  3. package/plugins/component-testing.js +6 -14
  4. package/src/builders/utilities/module-federation.js +4 -3
  5. package/src/executors/application/schema.json +4 -2
  6. package/src/executors/application/utils/validate-options.js +10 -0
  7. package/src/generators/application/application.js +8 -2
  8. package/src/generators/host/lib/update-ssr-setup.js +4 -4
  9. package/src/generators/library/lib/create-files.js +2 -1
  10. package/src/generators/move/lib/update-module-name.js +7 -5
  11. package/src/generators/ngrx/files/__directory__/__fileName__.facade.spec.ts__tmpl__ +13 -9
  12. package/src/generators/ngrx/lib/generate-files.js +1 -0
  13. package/src/generators/ngrx/lib/normalize-options.d.ts +1 -0
  14. package/src/generators/ngrx/lib/normalize-options.js +3 -0
  15. package/src/generators/ngrx-feature-store/files/__directory__/__fileName__.facade.spec.ts__tmpl__ +13 -9
  16. package/src/generators/ngrx-feature-store/lib/generate-files.js +1 -0
  17. package/src/generators/ngrx-feature-store/lib/normalize-options.d.ts +1 -0
  18. package/src/generators/ngrx-feature-store/lib/normalize-options.js +3 -0
  19. package/src/generators/ngrx-root-store/lib/normalize-options.js +5 -4
  20. package/src/generators/remote/lib/update-ssr-setup.js +4 -4
  21. package/src/generators/setup-mf/lib/add-cypress-workaround.js +2 -1
  22. package/src/generators/setup-mf/lib/add-remote-to-host.js +9 -7
  23. package/src/generators/setup-mf/lib/remove-dead-code-from-remote.js +8 -6
  24. package/src/generators/setup-ssr/lib/add-dependencies.js +2 -1
  25. package/src/generators/setup-ssr/lib/add-hydration.js +5 -3
  26. package/src/generators/setup-ssr/lib/add-server-file.js +2 -1
  27. package/src/generators/setup-ssr/lib/generate-files.js +2 -1
  28. package/src/generators/setup-ssr/lib/update-project-config.js +3 -2
  29. package/src/generators/setup-tailwind/lib/add-tailwind-config.js +2 -1
  30. package/src/generators/setup-tailwind/lib/update-application-styles.js +6 -4
  31. package/src/generators/utils/app-components-info.js +6 -4
  32. package/src/generators/utils/testing.js +2 -1
  33. package/src/migrations/update-17-1-0/replace-nguniversal-engines.js +2 -1
  34. package/src/migrations/update-21-3-0/update-angular-cli.d.ts +3 -0
  35. package/src/migrations/update-21-3-0/update-angular-cli.js +23 -0
  36. package/src/utils/backward-compatible-versions.js +2 -0
  37. package/src/utils/nx-devkit/ast-utils.js +3 -2
  38. package/src/utils/versions.d.ts +4 -3
  39. package/src/utils/versions.js +5 -4
package/migrations.json CHANGED
@@ -343,6 +343,15 @@
343
343
  },
344
344
  "description": "Update 'moduleResolution' to 'bundler' in TypeScript configurations. You can read more about this here: https://www.typescriptlang.org/tsconfig/#moduleResolution.",
345
345
  "factory": "./src/migrations/update-21-2-0/update-module-resolution"
346
+ },
347
+ "update-angular-cli-version-20-1-0": {
348
+ "cli": "nx",
349
+ "version": "21.3.0-beta.4",
350
+ "requires": {
351
+ "@angular/core": ">=20.1.0"
352
+ },
353
+ "description": "Update the @angular/cli package version to ~20.1.0.",
354
+ "factory": "./src/migrations/update-21-3-0/update-angular-cli"
346
355
  }
347
356
  },
348
357
  "packageJsonUpdates": {
@@ -1809,6 +1818,71 @@
1809
1818
  "alwaysAddToPackageJson": false
1810
1819
  }
1811
1820
  }
1821
+ },
1822
+ "21.3.0": {
1823
+ "version": "21.3.0-beta.4",
1824
+ "x-prompt": "Do you want to update the Angular version to v20.1?",
1825
+ "requires": {
1826
+ "@angular/core": ">=20.0.0 <20.1.0"
1827
+ },
1828
+ "packages": {
1829
+ "@angular-devkit/build-angular": {
1830
+ "version": "~20.1.0",
1831
+ "alwaysAddToPackageJson": false
1832
+ },
1833
+ "@angular-devkit/core": {
1834
+ "version": "~20.1.0",
1835
+ "alwaysAddToPackageJson": false
1836
+ },
1837
+ "@angular-devkit/schematics": {
1838
+ "version": "~20.1.0",
1839
+ "alwaysAddToPackageJson": false
1840
+ },
1841
+ "@angular/build": {
1842
+ "version": "~20.1.0",
1843
+ "alwaysAddToPackageJson": false
1844
+ },
1845
+ "@angular/pwa": {
1846
+ "version": "~20.1.0",
1847
+ "alwaysAddToPackageJson": false
1848
+ },
1849
+ "@angular/ssr": {
1850
+ "version": "~20.1.0",
1851
+ "alwaysAddToPackageJson": false
1852
+ },
1853
+ "@schematics/angular": {
1854
+ "version": "~20.1.0",
1855
+ "alwaysAddToPackageJson": false
1856
+ },
1857
+ "@angular-devkit/architect": {
1858
+ "version": "~0.2001.0",
1859
+ "alwaysAddToPackageJson": false
1860
+ },
1861
+ "@angular-devkit/build-webpack": {
1862
+ "version": "~0.2001.0",
1863
+ "alwaysAddToPackageJson": false
1864
+ },
1865
+ "@angular/core": {
1866
+ "version": "~20.1.0",
1867
+ "alwaysAddToPackageJson": true
1868
+ },
1869
+ "@angular/material": {
1870
+ "version": "~20.1.0",
1871
+ "alwaysAddToPackageJson": false
1872
+ },
1873
+ "@angular/cdk": {
1874
+ "version": "~20.1.0",
1875
+ "alwaysAddToPackageJson": false
1876
+ },
1877
+ "@angular/google-maps": {
1878
+ "version": "~20.1.0",
1879
+ "alwaysAddToPackageJson": false
1880
+ },
1881
+ "ng-packagr": {
1882
+ "version": "~20.1.0",
1883
+ "alwaysAddToPackageJson": false
1884
+ }
1885
+ }
1812
1886
  }
1813
1887
  }
1814
1888
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/angular",
3
- "version": "21.3.0-canary.20250710-13551c9",
3
+ "version": "21.3.0-canary.20250712-18e5d95",
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, 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.",
6
6
  "repository": {
@@ -58,14 +58,14 @@
58
58
  "migrations": "./migrations.json"
59
59
  },
60
60
  "dependencies": {
61
- "@nx/devkit": "21.3.0-canary.20250710-13551c9",
62
- "@nx/eslint": "21.3.0-canary.20250710-13551c9",
63
- "@nx/js": "21.3.0-canary.20250710-13551c9",
64
- "@nx/module-federation": "21.3.0-canary.20250710-13551c9",
65
- "@nx/rspack": "21.3.0-canary.20250710-13551c9",
66
- "@nx/web": "21.3.0-canary.20250710-13551c9",
67
- "@nx/webpack": "21.3.0-canary.20250710-13551c9",
68
- "@nx/workspace": "21.3.0-canary.20250710-13551c9",
61
+ "@nx/devkit": "21.3.0-canary.20250712-18e5d95",
62
+ "@nx/eslint": "21.3.0-canary.20250712-18e5d95",
63
+ "@nx/js": "21.3.0-canary.20250712-18e5d95",
64
+ "@nx/module-federation": "21.3.0-canary.20250712-18e5d95",
65
+ "@nx/rspack": "21.3.0-canary.20250712-18e5d95",
66
+ "@nx/web": "21.3.0-canary.20250712-18e5d95",
67
+ "@nx/webpack": "21.3.0-canary.20250712-18e5d95",
68
+ "@nx/workspace": "21.3.0-canary.20250712-18e5d95",
69
69
  "@phenomnomnominal/tsquery": "~5.0.1",
70
70
  "@typescript-eslint/type-utils": "^8.0.0",
71
71
  "enquirer": "~2.3.6",
@@ -4,6 +4,7 @@ exports.nxComponentTestingPreset = nxComponentTestingPreset;
4
4
  const cypress_preset_1 = require("@nx/cypress/plugins/cypress-preset");
5
5
  const ct_helpers_1 = require("@nx/cypress/src/utils/ct-helpers");
6
6
  const devkit_1 = require("@nx/devkit");
7
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
8
  const fs_1 = require("fs");
8
9
  const path_1 = require("path");
9
10
  const semver_1 = require("semver");
@@ -115,7 +116,8 @@ function normalizeBuildTargetOptions(buildContext, ctContext, offset) {
115
116
  configuration: buildContext.configurationName,
116
117
  }, buildContext);
117
118
  const project = buildContext.projectsConfigurations.projects[buildContext.projectName];
118
- const buildOptions = withSchemaDefaults(options, project, buildContext.root);
119
+ const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(project);
120
+ const buildOptions = withSchemaDefaults(options, sourceRoot, buildContext.root);
119
121
  // cypress creates a tsconfig if one isn't preset
120
122
  // that contains all the support required for angular and component tests
121
123
  delete buildOptions.tsConfig;
@@ -189,18 +191,9 @@ function normalizeBuildTargetOptions(buildContext, ctContext, offset) {
189
191
  buildOptions.scripts = [];
190
192
  buildOptions.stylePreprocessorOptions = { includePaths: [] };
191
193
  }
192
- const config = buildContext.projectGraph.nodes[buildContext.projectName]?.data;
193
- if (!config.sourceRoot) {
194
- devkit_1.logger.warn((0, devkit_1.stripIndents) `Unable to find the 'sourceRoot' in the project configuration.
195
- Will set 'sourceRoot' to '${config.root}/src'
196
- Note: this may fail, setting the correct 'sourceRoot' for ${buildContext.projectName} in the project.json file will ensure the correct value is used.`);
197
- config.sourceRoot = (0, devkit_1.joinPathFragments)(config.root, 'src');
198
- }
199
194
  return {
200
- root: offset ? (0, devkit_1.joinPathFragments)(offset, config.root) : config.root,
201
- sourceRoot: offset
202
- ? (0, devkit_1.joinPathFragments)(offset, config.sourceRoot)
203
- : config.sourceRoot,
195
+ root: offset ? (0, devkit_1.joinPathFragments)(offset, project.root) : project.root,
196
+ sourceRoot: offset ? (0, devkit_1.joinPathFragments)(offset, sourceRoot) : sourceRoot,
204
197
  buildOptions: {
205
198
  ...buildOptions,
206
199
  // this property is only valid for cy v12.9.0+
@@ -208,9 +201,8 @@ Note: this may fail, setting the correct 'sourceRoot' for ${buildContext.project
208
201
  },
209
202
  };
210
203
  }
211
- function withSchemaDefaults(options, project, workspaceRoot) {
204
+ function withSchemaDefaults(options, sourceRoot, workspaceRoot) {
212
205
  if (!options.main && !options.browser) {
213
- const sourceRoot = project.sourceRoot ?? (0, devkit_1.joinPathFragments)(project.root, 'src');
214
206
  options.browser = (0, devkit_1.joinPathFragments)(sourceRoot, 'main.ts');
215
207
  if (!(0, fs_1.existsSync)((0, path_1.join)(workspaceRoot, options.browser))) {
216
208
  throw new Error('Missing executor options "main" and "browser"');
@@ -4,10 +4,11 @@ exports.getDynamicRemotes = getDynamicRemotes;
4
4
  exports.getStaticRemotes = getStaticRemotes;
5
5
  exports.validateDevRemotes = validateDevRemotes;
6
6
  exports.getDynamicMfManifestFile = getDynamicMfManifestFile;
7
- const path_1 = require("path");
8
- const fs_1 = require("fs");
9
7
  const devkit_1 = require("@nx/devkit");
10
8
  const internal_1 = require("@nx/js/src/internal");
9
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
10
+ const fs_1 = require("fs");
11
+ const path_1 = require("path");
11
12
  function getDynamicRemotes(project, context, workspaceProjects, remotesToSkip, pathToManifestFile) {
12
13
  pathToManifestFile ??= getDynamicMfManifestFile(project, context.workspaceRoot);
13
14
  // check for dynamic remotes
@@ -105,6 +106,6 @@ function getDynamicMfManifestFile(project, workspaceRoot) {
105
106
  // at the old path.
106
107
  return [
107
108
  (0, path_1.join)(workspaceRoot, project.root, 'public/module-federation.manifest.json'),
108
- (0, path_1.join)(workspaceRoot, project.sourceRoot, 'assets/module-federation.manifest.json'),
109
+ (0, path_1.join)(workspaceRoot, (0, ts_solution_setup_1.getProjectSourceRoot)(project), 'assets/module-federation.manifest.json'),
109
110
  ].find((path) => (0, fs_1.existsSync)(path));
110
111
  }
@@ -278,10 +278,12 @@
278
278
  ]
279
279
  },
280
280
  "loader": {
281
- "description": "Defines the type of loader to use with a specified file extension when used with a JavaScript `import`. `text` inlines the content as a string; `binary` inlines the content as a Uint8Array; `file` emits the file and provides the runtime location of the file; `empty` considers the content to be empty and not include it in bundles.",
281
+ "description": "Defines the type of loader to use with a specified file extension when used with a JavaScript `import`. `text` inlines the content as a string; `binary` inlines the content as a Uint8Array; `file` emits the file and provides the runtime location of the file; `dataurl` inlines the content as a data URL with best guess of MIME type; `base64` inlines the content as a Base64-encoded string; `empty` considers the content to be empty and not include it in bundles. _Note: `dataurl` and `base64` are only supported in Angular versions >= 20.1.0_.",
282
282
  "type": "object",
283
283
  "patternProperties": {
284
- "^\\.\\S+$": { "enum": ["text", "binary", "file", "empty"] }
284
+ "^\\.\\S+$": {
285
+ "enum": ["text", "binary", "file", "dataurl", "base64", "empty"]
286
+ }
285
287
  }
286
288
  },
287
289
  "define": {
@@ -32,4 +32,14 @@ function validateOptions(options) {
32
32
  throw new Error(`The "conditions" option requires Angular version 20.0.0 or greater. You are currently using version ${angularVersion}.`);
33
33
  }
34
34
  }
35
+ if ((0, semver_1.lt)(angularVersion, '20.1.0')) {
36
+ if (options.loader) {
37
+ const invalidLoaders = Array.from(new Set(Object.values(options.loader).filter((l) => l === 'dataurl' || l === 'base64')));
38
+ if (invalidLoaders.length) {
39
+ throw new Error(`Using the ${invalidLoaders
40
+ .map((l) => `"${l}"`)
41
+ .join(' and ')} loader${invalidLoaders.length > 1 ? 's' : ''} requires Angular version 20.1.0 or greater. You are currently using version ${angularVersion}.`);
42
+ }
43
+ }
44
+ }
35
45
  }
@@ -80,10 +80,11 @@ async function applicationGenerator(tree, schema) {
80
80
  }
81
81
  if (!options.skipPackageJson) {
82
82
  const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
83
+ const devDependencies = {};
84
+ const packageVersions = (0, version_utils_1.versions)(tree);
83
85
  if (angularMajorVersion >= 20) {
84
86
  const angularDevkitVersion = (0, version_utils_1.getInstalledAngularDevkitVersion)(tree) ??
85
- (0, version_utils_1.versions)(tree).angularDevkitVersion;
86
- const devDependencies = {};
87
+ packageVersions.angularDevkitVersion;
87
88
  if (options.bundler === 'esbuild') {
88
89
  devDependencies['@angular/build'] = angularDevkitVersion;
89
90
  }
@@ -94,6 +95,11 @@ async function applicationGenerator(tree, schema) {
94
95
  else {
95
96
  devDependencies['@angular-devkit/build-angular'] = angularDevkitVersion;
96
97
  }
98
+ }
99
+ if (options.style === 'less') {
100
+ devDependencies['less'] = packageVersions.lessVersion;
101
+ }
102
+ if (Object.keys(devDependencies).length) {
97
103
  (0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies, undefined, true);
98
104
  }
99
105
  }
@@ -2,16 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateSsrSetup = updateSsrSetup;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
5
6
  const path_1 = require("path");
6
7
  const versions_1 = require("../../../utils/versions");
7
8
  const version_utils_1 = require("../../utils/version-utils");
8
9
  async function updateSsrSetup(tree, options, appName, typescriptConfiguration) {
9
10
  const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
10
11
  let project = (0, devkit_1.readProjectConfiguration)(tree, appName);
11
- tree.rename((0, devkit_1.joinPathFragments)(project.sourceRoot, 'main.server.ts'), (0, devkit_1.joinPathFragments)(project.sourceRoot, 'bootstrap.server.ts'));
12
- const pathToServerEntry = (0, devkit_1.joinPathFragments)(angularMajorVersion >= 19
13
- ? project.sourceRoot ?? (0, devkit_1.joinPathFragments)(project.root, 'src')
14
- : project.root, 'server.ts');
12
+ const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(project, tree);
13
+ tree.rename((0, devkit_1.joinPathFragments)(sourceRoot, 'main.server.ts'), (0, devkit_1.joinPathFragments)(sourceRoot, 'bootstrap.server.ts'));
14
+ const pathToServerEntry = (0, devkit_1.joinPathFragments)(angularMajorVersion >= 19 ? sourceRoot : project.root, 'server.ts');
15
15
  tree.write(pathToServerEntry, `import('./${angularMajorVersion >= 19 ? '' : 'src/'}main.server');`);
16
16
  (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, '../files/common'), project.root, {
17
17
  appName,
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createFiles = createFiles;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const js_1 = require("@nx/js");
6
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
6
7
  const semver_1 = require("semver");
7
8
  const test_runners_1 = require("../../../utils/test-runners");
8
9
  const version_utils_1 = require("../../utils/version-utils");
@@ -50,7 +51,7 @@ function createFiles(tree, options, project) {
50
51
  }
51
52
  }
52
53
  if (!options.libraryOptions.routing) {
53
- tree.delete((0, devkit_1.joinPathFragments)(project.sourceRoot, `lib/lib.routes.ts`));
54
+ tree.delete((0, devkit_1.joinPathFragments)((0, ts_solution_setup_1.getProjectSourceRoot)(project, tree), `lib/lib.routes.ts`));
54
55
  }
55
56
  if (!options.libraryOptions.buildable &&
56
57
  !options.libraryOptions.publishable) {
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateModuleName = updateModuleName;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
5
6
  /**
6
7
  * Updates the Angular module name (including the spec file and index.ts)
7
8
  *
@@ -40,14 +41,15 @@ function updateModuleName(tree, { oldProjectName, newProjectName }) {
40
41
  to: `${unscopedNewProjectName}-module`,
41
42
  },
42
43
  ];
44
+ const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(project, tree);
43
45
  const filesToRename = moduleFiles.flatMap((moduleFile) => [
44
46
  {
45
- from: `${project.sourceRoot}/lib/${moduleFile.from}.ts`,
46
- to: `${project.sourceRoot}/lib/${moduleFile.to}.ts`,
47
+ from: `${sourceRoot}/lib/${moduleFile.from}.ts`,
48
+ to: `${sourceRoot}/lib/${moduleFile.to}.ts`,
47
49
  },
48
50
  {
49
- from: `${project.sourceRoot}/lib/${moduleFile.from}.spec.ts`,
50
- to: `${project.sourceRoot}/lib/${moduleFile.to}.spec.ts`,
51
+ from: `${sourceRoot}/lib/${moduleFile.from}.spec.ts`,
52
+ to: `${sourceRoot}/lib/${moduleFile.to}.spec.ts`,
51
53
  },
52
54
  ].filter((rename) => rename.from !== rename.to));
53
55
  if (filesToRename.length === 0) {
@@ -71,7 +73,7 @@ function updateModuleName(tree, { oldProjectName, newProjectName }) {
71
73
  }
72
74
  });
73
75
  // update index file
74
- const indexFile = (0, devkit_1.joinPathFragments)(project.sourceRoot, 'index.ts');
76
+ const indexFile = (0, devkit_1.joinPathFragments)(sourceRoot, 'index.ts');
75
77
  if (tree.exists(indexFile)) {
76
78
  updateFileContent(tree, replacements, indexFile);
77
79
  }
@@ -2,7 +2,11 @@ import { NgModule } from '@angular/core';
2
2
  import { TestBed } from '@angular/core/testing';
3
3
  import { EffectsModule } from '@ngrx/effects';
4
4
  import { StoreModule, Store } from '@ngrx/store';
5
- import { readFirst } from '@nx/angular/testing';
5
+ <%_ if (isRxJs7) { _%>
6
+ import { firstValueFrom } from 'rxjs';
7
+ <%_ } else { _%>
8
+ import { first } from 'rxjs/operators';
9
+ <%_ } _%>
6
10
 
7
11
  import * as <%= className %>Actions from './<%= fileName %>.actions';
8
12
  import { <%= className %>Effects } from './<%= fileName %>.effects';
@@ -57,16 +61,16 @@ describe('<%= className %>Facade', () => {
57
61
  * The initially generated facade::loadAll() returns empty array
58
62
  */
59
63
  it('loadAll() should return empty list with loaded == true', async () => {
60
- let list = await readFirst(facade.all<%= className %>$);
61
- let isLoaded = await readFirst(facade.loaded$);
64
+ let list = await <% if (isRxJs7) { %>firstValueFrom(facade.all<%= className %>$)<% } else { %>facade.all<%= className %>$.pipe(first()).toPromise()<% } %>;
65
+ let isLoaded = await <% if (isRxJs7) { %>firstValueFrom(facade.loaded$)<% } else { %>facade.loaded$.pipe(first()).toPromise()<% } %>;
62
66
 
63
67
  expect(list.length).toBe(0);
64
68
  expect(isLoaded).toBe(false);
65
69
 
66
70
  facade.init();
67
71
 
68
- list = await readFirst(facade.all<%= className %>$);
69
- isLoaded = await readFirst(facade.loaded$);
72
+ list = await <% if (isRxJs7) { %>firstValueFrom(facade.all<%= className %>$)<% } else { %>facade.all<%= className %>$.pipe(first()).toPromise()<% } %>;
73
+ isLoaded = await <% if (isRxJs7) { %>firstValueFrom(facade.loaded$)<% } else { %>facade.loaded$.pipe(first()).toPromise()<% } %>;
70
74
 
71
75
  expect(list.length).toBe(0);
72
76
  expect(isLoaded).toBe(true);
@@ -76,8 +80,8 @@ describe('<%= className %>Facade', () => {
76
80
  * Use `load<%= className %>Success` to manually update list
77
81
  */
78
82
  it('all<%= className %>$ should return the loaded list; and loaded flag == true', async () => {
79
- let list = await readFirst(facade.all<%= className %>$);
80
- let isLoaded = await readFirst(facade.loaded$);
83
+ let list = await <% if (isRxJs7) { %>firstValueFrom(facade.all<%= className %>$)<% } else { %>facade.all<%= className %>$.pipe(first()).toPromise()<% } %>;
84
+ let isLoaded = await <% if (isRxJs7) { %>firstValueFrom(facade.loaded$)<% } else { %>facade.loaded$.pipe(first()).toPromise()<% } %>;
81
85
 
82
86
  expect(list.length).toBe(0);
83
87
  expect(isLoaded).toBe(false);
@@ -89,8 +93,8 @@ describe('<%= className %>Facade', () => {
89
93
  ]})
90
94
  );
91
95
 
92
- list = await readFirst(facade.all<%= className %>$);
93
- isLoaded = await readFirst(facade.loaded$);
96
+ list = await <% if (isRxJs7) { %>firstValueFrom(facade.all<%= className %>$)<% } else { %>facade.all<%= className %>$.pipe(first()).toPromise()<% } %>;
97
+ isLoaded = await <% if (isRxJs7) { %>firstValueFrom(facade.loaded$)<% } else { %>facade.loaded$.pipe(first()).toPromise()<% } %>;
94
98
 
95
99
  expect(list.length).toBe(2);
96
100
  expect(isLoaded).toBe(true);
@@ -13,6 +13,7 @@ function generateNgrxFilesFromTemplates(tree, options) {
13
13
  ...options,
14
14
  ...projectNames,
15
15
  importFromOperators: (0, semver_1.lt)(options.rxjsVersion, '7.2.0'),
16
+ isRxJs7: options.rxjsMajorVersion >= 7,
16
17
  tmpl: '',
17
18
  });
18
19
  if (!options.facade) {
@@ -3,5 +3,6 @@ import type { NgRxGeneratorOptions } from '../schema';
3
3
  export type NormalizedNgRxGeneratorOptions = NgRxGeneratorOptions & {
4
4
  parentDirectory: string;
5
5
  rxjsVersion: string;
6
+ rxjsMajorVersion: number;
6
7
  };
7
8
  export declare function normalizeOptions(tree: Tree, options: NgRxGeneratorOptions): NormalizedNgRxGeneratorOptions;
@@ -4,6 +4,7 @@ exports.normalizeOptions = normalizeOptions;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const semver_1 = require("@nx/devkit/src/utils/semver");
6
6
  const path_1 = require("path");
7
+ const semver_2 = require("semver");
7
8
  const versions_1 = require("../../../utils/versions");
8
9
  function normalizeOptions(tree, options) {
9
10
  let rxjsVersion;
@@ -13,6 +14,7 @@ function normalizeOptions(tree, options) {
13
14
  catch {
14
15
  rxjsVersion = (0, semver_1.checkAndCleanWithSemver)('rxjs', versions_1.rxjsVersion);
15
16
  }
17
+ const rxjsMajorVersion = (0, semver_2.major)(rxjsVersion);
16
18
  return {
17
19
  ...options,
18
20
  parentDirectory: options.module
@@ -23,5 +25,6 @@ function normalizeOptions(tree, options) {
23
25
  route: options.route === '' ? `''` : options.route ?? `''`,
24
26
  directory: (0, devkit_1.names)(options.directory).fileName,
25
27
  rxjsVersion,
28
+ rxjsMajorVersion,
26
29
  };
27
30
  }
@@ -2,7 +2,11 @@ import { NgModule } from '@angular/core';
2
2
  import { TestBed } from '@angular/core/testing';
3
3
  import { EffectsModule } from '@ngrx/effects';
4
4
  import { StoreModule, Store } from '@ngrx/store';
5
- import { readFirst } from '@nx/angular/testing';
5
+ <%_ if (isRxJs7) { _%>
6
+ import { firstValueFrom } from 'rxjs';
7
+ <%_ } else { _%>
8
+ import { first } from 'rxjs/operators';
9
+ <%_ } _%>
6
10
 
7
11
  import * as <%= className %>Actions from './<%= relativeFileName %>.actions';
8
12
  import { <%= className %>Effects } from './<%= relativeFileName %>.effects';
@@ -57,16 +61,16 @@ describe('<%= className %>Facade', () => {
57
61
  * The initially generated facade::loadAll() returns empty array
58
62
  */
59
63
  it('loadAll() should return empty list with loaded == true', async () => {
60
- let list = await readFirst(facade.all<%= className %>$);
61
- let isLoaded = await readFirst(facade.loaded$);
64
+ let list = await <% if (isRxJs7) { %>firstValueFrom(facade.all<%= className %>$)<% } else { %>facade.all<%= className %>$.pipe(first()).toPromise()<% } %>;
65
+ let isLoaded = await <% if (isRxJs7) { %>firstValueFrom(facade.loaded$)<% } else { %>facade.loaded$.pipe(first()).toPromise()<% } %>;
62
66
 
63
67
  expect(list.length).toBe(0);
64
68
  expect(isLoaded).toBe(false);
65
69
 
66
70
  facade.init();
67
71
 
68
- list = await readFirst(facade.all<%= className %>$);
69
- isLoaded = await readFirst(facade.loaded$);
72
+ list = await <% if (isRxJs7) { %>firstValueFrom(facade.all<%= className %>$)<% } else { %>facade.all<%= className %>$.pipe(first()).toPromise()<% } %>;
73
+ isLoaded = await <% if (isRxJs7) { %>firstValueFrom(facade.loaded$)<% } else { %>facade.loaded$.pipe(first()).toPromise()<% } %>;
70
74
 
71
75
  expect(list.length).toBe(0);
72
76
  expect(isLoaded).toBe(true);
@@ -76,8 +80,8 @@ describe('<%= className %>Facade', () => {
76
80
  * Use `load<%= className %>Success` to manually update list
77
81
  */
78
82
  it('all<%= className %>$ should return the loaded list; and loaded flag == true', async () => {
79
- let list = await readFirst(facade.all<%= className %>$);
80
- let isLoaded = await readFirst(facade.loaded$);
83
+ let list = await <% if (isRxJs7) { %>firstValueFrom(facade.all<%= className %>$)<% } else { %>facade.all<%= className %>$.pipe(first()).toPromise()<% } %>;
84
+ let isLoaded = await <% if (isRxJs7) { %>firstValueFrom(facade.loaded$)<% } else { %>facade.loaded$.pipe(first()).toPromise()<% } %>;
81
85
 
82
86
  expect(list.length).toBe(0);
83
87
  expect(isLoaded).toBe(false);
@@ -89,8 +93,8 @@ describe('<%= className %>Facade', () => {
89
93
  ]})
90
94
  );
91
95
 
92
- list = await readFirst(facade.all<%= className %>$);
93
- isLoaded = await readFirst(facade.loaded$);
96
+ list = await <% if (isRxJs7) { %>firstValueFrom(facade.all<%= className %>$)<% } else { %>facade.all<%= className %>$.pipe(first()).toPromise()<% } %>;
97
+ isLoaded = await <% if (isRxJs7) { %>firstValueFrom(facade.loaded$)<% } else { %>facade.loaded$.pipe(first()).toPromise()<% } %>;
94
98
 
95
99
  expect(list.length).toBe(2);
96
100
  expect(isLoaded).toBe(true);
@@ -14,6 +14,7 @@ function generateFilesFromTemplates(tree, options) {
14
14
  fileName,
15
15
  relativeFileName: projectNames.fileName,
16
16
  importFromOperators: (0, semver_1.lt)(options.rxjsVersion, '7.2.0'),
17
+ isRxJs7: options.rxjsMajorVersion >= 7,
17
18
  tmpl: '',
18
19
  });
19
20
  if (!options.facade) {
@@ -4,5 +4,6 @@ export type NormalizedNgRxFeatureStoreGeneratorOptions = Schema & {
4
4
  parentDirectory: string;
5
5
  subdirectory: string;
6
6
  rxjsVersion: string;
7
+ rxjsMajorVersion: number;
7
8
  };
8
9
  export declare function normalizeOptions(tree: Tree, options: Schema): NormalizedNgRxFeatureStoreGeneratorOptions;
@@ -4,6 +4,7 @@ exports.normalizeOptions = normalizeOptions;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const semver_1 = require("@nx/devkit/src/utils/semver");
6
6
  const path_1 = require("path");
7
+ const semver_2 = require("semver");
7
8
  const versions_1 = require("../../../utils/versions");
8
9
  function normalizeOptions(tree, options) {
9
10
  let rxjsVersion;
@@ -13,6 +14,7 @@ function normalizeOptions(tree, options) {
13
14
  catch {
14
15
  rxjsVersion = (0, semver_1.checkAndCleanWithSemver)('rxjs', versions_1.rxjsVersion);
15
16
  }
17
+ const rxjsMajorVersion = (0, semver_2.major)(rxjsVersion);
16
18
  const { subdirectory, name } = determineSubdirectoryAndName(options.name);
17
19
  return {
18
20
  ...options,
@@ -22,6 +24,7 @@ function normalizeOptions(tree, options) {
22
24
  route: options.route === '' ? `''` : options.route ?? `''`,
23
25
  directory: (0, devkit_1.names)(options.directory).fileName,
24
26
  rxjsVersion,
27
+ rxjsMajorVersion,
25
28
  };
26
29
  }
27
30
  function determineSubdirectoryAndName(name) {
@@ -5,6 +5,7 @@ const devkit_1 = require("@nx/devkit");
5
5
  const semver_1 = require("@nx/devkit/src/utils/semver");
6
6
  const versions_1 = require("../../../utils/versions");
7
7
  const ast_utils_1 = require("../../../utils/nx-devkit/ast-utils");
8
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
8
9
  function normalizeOptions(tree, options) {
9
10
  let rxjsVersion;
10
11
  try {
@@ -15,10 +16,10 @@ function normalizeOptions(tree, options) {
15
16
  }
16
17
  const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
17
18
  const isStandalone = (0, ast_utils_1.isNgStandaloneApp)(tree, options.project);
18
- const appConfigPath = (0, devkit_1.joinPathFragments)(project.sourceRoot, 'app/app.config.ts');
19
+ const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(project, tree);
20
+ const appConfigPath = (0, devkit_1.joinPathFragments)(sourceRoot, 'app/app.config.ts');
19
21
  let appMainPath = project.targets.build.options.main ?? project.targets.build.options.browser;
20
22
  if (!appMainPath) {
21
- const sourceRoot = project.sourceRoot ?? (0, devkit_1.joinPathFragments)(project.root, 'src');
22
23
  appMainPath = (0, devkit_1.joinPathFragments)(sourceRoot, 'main.ts');
23
24
  }
24
25
  /** If NgModule App
@@ -28,9 +29,9 @@ function normalizeOptions(tree, options) {
28
29
  * --> If so, use that
29
30
  * --> If not, use main.ts
30
31
  */
31
- let ngModulePath = (0, devkit_1.joinPathFragments)(project.sourceRoot, 'app/app.module.ts');
32
+ let ngModulePath = (0, devkit_1.joinPathFragments)(sourceRoot, 'app/app.module.ts');
32
33
  if (!tree.exists(ngModulePath)) {
33
- ngModulePath = (0, devkit_1.joinPathFragments)(project.sourceRoot, 'app/app-module.ts');
34
+ ngModulePath = (0, devkit_1.joinPathFragments)(sourceRoot, 'app/app-module.ts');
34
35
  }
35
36
  const parent = !isStandalone && tree.exists(ngModulePath)
36
37
  ? ngModulePath
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateSsrSetup = updateSsrSetup;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
5
6
  const path_1 = require("path");
6
7
  const versions_1 = require("../../../utils/versions");
7
8
  const artifact_types_1 = require("../../utils/artifact-types");
@@ -9,10 +10,9 @@ const version_utils_1 = require("../../utils/version-utils");
9
10
  async function updateSsrSetup(tree, { appName, port, standalone, typescriptConfiguration, skipPackageJson, }) {
10
11
  const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
11
12
  let project = (0, devkit_1.readProjectConfiguration)(tree, appName);
12
- tree.rename((0, devkit_1.joinPathFragments)(project.sourceRoot, 'main.server.ts'), (0, devkit_1.joinPathFragments)(project.sourceRoot, 'bootstrap.server.ts'));
13
- const pathToServerEntry = (0, devkit_1.joinPathFragments)(angularMajorVersion >= 19
14
- ? project.sourceRoot ?? (0, devkit_1.joinPathFragments)(project.root, 'src')
15
- : project.root, 'server.ts');
13
+ const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(project, tree);
14
+ tree.rename((0, devkit_1.joinPathFragments)(sourceRoot, 'main.server.ts'), (0, devkit_1.joinPathFragments)(sourceRoot, 'bootstrap.server.ts'));
15
+ const pathToServerEntry = (0, devkit_1.joinPathFragments)(angularMajorVersion >= 19 ? sourceRoot : project.root, 'server.ts');
16
16
  tree.write(pathToServerEntry, `import('./${angularMajorVersion >= 19 ? '' : 'src/'}main.server');`);
17
17
  const browserBundleOutput = project.targets.build.options.outputPath;
18
18
  const serverBundleOutput = project.targets.build.options.outputPath.replace(/\/browser$/, '/server');
@@ -5,6 +5,7 @@
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.addCypressOnErrorWorkaround = addCypressOnErrorWorkaround;
7
7
  const devkit_1 = require("@nx/devkit");
8
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
8
9
  function addCypressOnErrorWorkaround(tree, schema) {
9
10
  if (!schema.e2eProjectName) {
10
11
  return;
@@ -43,7 +44,7 @@ function addCypressOnErrorWorkaround(tree, schema) {
43
44
  }
44
45
  return true;
45
46
  });`;
46
- const pathToCommandsFile = (0, devkit_1.joinPathFragments)(e2eProject.sourceRoot, 'support/e2e.ts');
47
+ const pathToCommandsFile = (0, devkit_1.joinPathFragments)((0, ts_solution_setup_1.getProjectSourceRoot)(e2eProject, tree), 'support/e2e.ts');
47
48
  const commandsContent = tree.exists(pathToCommandsFile)
48
49
  ? tree.read(pathToCommandsFile, 'utf-8')
49
50
  : '';
@@ -4,8 +4,9 @@ exports.checkIsCommaNeeded = checkIsCommaNeeded;
4
4
  exports.addRemoteToHost = addRemoteToHost;
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const js_1 = require("@nx/js");
7
- const route_utils_1 = require("../../../utils/nx-devkit/route-utils");
8
7
  const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
8
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
9
+ const route_utils_1 = require("../../../utils/nx-devkit/route-utils");
9
10
  let tsModule;
10
11
  function checkIsCommaNeeded(mfRemoteText) {
11
12
  const remoteText = mfRemoteText.replace(/\s+/g, '');
@@ -25,7 +26,7 @@ function addRemoteToHost(tree, options) {
25
26
  addRemoteToStaticHost(tree, options, hostProject, isHostUsingTypescriptConfig);
26
27
  }
27
28
  else if (hostFederationType === 'dynamic') {
28
- addRemoteToDynamicHost(tree, options, pathToMFManifest, hostProject.sourceRoot);
29
+ addRemoteToDynamicHost(tree, options, pathToMFManifest, (0, ts_solution_setup_1.getProjectSourceRoot)(hostProject, tree));
29
30
  }
30
31
  addLazyLoadedRouteToHostAppModule(tree, options, hostFederationType);
31
32
  }
@@ -39,7 +40,7 @@ function getDynamicManifestFile(tree, project) {
39
40
  // at the old path.
40
41
  return [
41
42
  (0, devkit_1.joinPathFragments)(project.root, 'public/module-federation.manifest.json'),
42
- (0, devkit_1.joinPathFragments)(project.sourceRoot, 'assets/module-federation.manifest.json'),
43
+ (0, devkit_1.joinPathFragments)((0, ts_solution_setup_1.getProjectSourceRoot)(project, tree), 'assets/module-federation.manifest.json'),
43
44
  ].find((path) => tree.exists(path));
44
45
  }
45
46
  function addRemoteToStaticHost(tree, options, hostProject, isHostUsingTypescript) {
@@ -75,7 +76,8 @@ function addLazyLoadedRouteToHostAppModule(tree, options, hostFederationType) {
75
76
  tsModule = (0, ensure_typescript_1.ensureTypescript)();
76
77
  }
77
78
  const hostAppConfig = (0, devkit_1.readProjectConfiguration)(tree, options.host);
78
- const pathToHostRootRouting = `${hostAppConfig.sourceRoot}/app/app.routes.ts`;
79
+ const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(hostAppConfig, tree);
80
+ const pathToHostRootRouting = `${sourceRoot}/app/app.routes.ts`;
79
81
  if (!tree.exists(pathToHostRootRouting)) {
80
82
  return;
81
83
  }
@@ -84,7 +86,7 @@ function addLazyLoadedRouteToHostAppModule(tree, options, hostFederationType) {
84
86
  // TODO(Colum): Remove for Nx 22
85
87
  const usingLegacyDynamicFederation = hostFederationType === 'dynamic' &&
86
88
  tree
87
- .read(`${hostAppConfig.sourceRoot}/main.ts`, 'utf-8')
89
+ .read(`${sourceRoot}/main.ts`, 'utf-8')
88
90
  .includes('setRemoteDefinitions(');
89
91
  if (hostFederationType === 'dynamic') {
90
92
  sourceFile = (0, js_1.insertImport)(tree, sourceFile, pathToHostRootRouting, usingLegacyDynamicFederation ? 'loadRemoteModule' : 'loadRemote', usingLegacyDynamicFederation
@@ -105,10 +107,10 @@ function addLazyLoadedRouteToHostAppModule(tree, options, hostFederationType) {
105
107
  path: '${options.appName}',
106
108
  loadChildren: () => ${routeToAdd}.then(m => m!.${exportedRemote})
107
109
  }`);
108
- let pathToAppComponentTemplate = (0, devkit_1.joinPathFragments)(hostAppConfig.sourceRoot, 'app/app.component.html');
110
+ let pathToAppComponentTemplate = (0, devkit_1.joinPathFragments)(sourceRoot, 'app/app.component.html');
109
111
  const candidatePaths = [
110
112
  pathToAppComponentTemplate,
111
- (0, devkit_1.joinPathFragments)(hostAppConfig.sourceRoot, 'app/app.html'),
113
+ (0, devkit_1.joinPathFragments)(sourceRoot, 'app/app.html'),
112
114
  ];
113
115
  for (const path of candidatePaths) {
114
116
  if (tree.exists(path)) {
@@ -2,19 +2,21 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.removeDeadCodeFromRemote = removeDeadCodeFromRemote;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
5
6
  function removeDeadCodeFromRemote(tree, options) {
6
7
  const projectName = options.appName;
7
8
  const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
9
+ const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(project, tree);
8
10
  const { appComponentInfo, nxWelcomeComponentInfo, entryModuleFileName } = options;
9
11
  ['css', 'less', 'scss', 'sass'].forEach((style) => {
10
- const pathToComponentStyle = (0, devkit_1.joinPathFragments)(project.sourceRoot, `app/${appComponentInfo.extensionlessFileName}.${style}`);
12
+ const pathToComponentStyle = (0, devkit_1.joinPathFragments)(sourceRoot, `app/${appComponentInfo.extensionlessFileName}.${style}`);
11
13
  if (tree.exists(pathToComponentStyle)) {
12
14
  tree.delete(pathToComponentStyle);
13
15
  }
14
16
  });
15
- tree.rename(nxWelcomeComponentInfo.path, (0, devkit_1.joinPathFragments)(project.sourceRoot, `app/remote-entry/${nxWelcomeComponentInfo.fileName}`));
16
- tree.delete((0, devkit_1.joinPathFragments)(project.sourceRoot, `app/${appComponentInfo.extensionlessFileName}.spec.ts`));
17
- tree.delete((0, devkit_1.joinPathFragments)(project.sourceRoot, `app/${appComponentInfo.extensionlessFileName}.html`));
17
+ tree.rename(nxWelcomeComponentInfo.path, (0, devkit_1.joinPathFragments)(sourceRoot, `app/remote-entry/${nxWelcomeComponentInfo.fileName}`));
18
+ tree.delete((0, devkit_1.joinPathFragments)(sourceRoot, `app/${appComponentInfo.extensionlessFileName}.spec.ts`));
19
+ tree.delete((0, devkit_1.joinPathFragments)(sourceRoot, `app/${appComponentInfo.extensionlessFileName}.html`));
18
20
  if (!options.standalone) {
19
21
  const componentContents = tree.read(appComponentInfo.path, 'utf-8');
20
22
  const isInlineTemplate = !componentContents.includes('templateUrl');
@@ -24,9 +26,9 @@ function removeDeadCodeFromRemote(tree, options) {
24
26
  })
25
27
  export class ${appComponentInfo.symbolName} {}`;
26
28
  tree.write(appComponentInfo.path, component);
27
- let modulePath = (0, devkit_1.joinPathFragments)(project.sourceRoot, 'app/app.module.ts');
29
+ let modulePath = (0, devkit_1.joinPathFragments)(sourceRoot, 'app/app.module.ts');
28
30
  if (!tree.exists(modulePath)) {
29
- modulePath = (0, devkit_1.joinPathFragments)(project.sourceRoot, 'app/app-module.ts');
31
+ modulePath = (0, devkit_1.joinPathFragments)(sourceRoot, 'app/app-module.ts');
30
32
  }
31
33
  tree.write(modulePath, `import { NgModule } from '@angular/core';
32
34
  import { BrowserModule } from '@angular/platform-browser';
@@ -12,6 +12,7 @@ function addDependencies(tree, isUsingApplicationBuilder) {
12
12
  };
13
13
  const devDependencies = {
14
14
  '@types/express': pkgVersions.typesExpressVersion,
15
+ '@types/node': pkgVersions.typesNodeVersion,
15
16
  };
16
17
  const angularDevkitVersion = (0, version_utils_1.getInstalledAngularDevkitVersion)(tree) ?? pkgVersions.angularDevkitVersion;
17
18
  dependencies['@angular/ssr'] = angularDevkitVersion;
@@ -24,5 +25,5 @@ function addDependencies(tree, isUsingApplicationBuilder) {
24
25
  dependencies['@angular-devkit/build-angular'] = angularDevkitVersion;
25
26
  }
26
27
  }
27
- (0, devkit_1.addDependenciesToPackageJson)(tree, dependencies, devDependencies);
28
+ (0, devkit_1.addDependenciesToPackageJson)(tree, dependencies, devDependencies, undefined, true);
28
29
  }
@@ -4,24 +4,26 @@ exports.addHydration = addHydration;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const js_1 = require("@nx/js");
6
6
  const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
7
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
8
  const ast_utils_1 = require("../../../utils/nx-devkit/ast-utils");
8
9
  const version_utils_1 = require("../../utils/version-utils");
9
10
  let tsModule;
10
11
  let tsquery;
11
12
  function addHydration(tree, options) {
12
13
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
14
+ const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(projectConfig, tree);
13
15
  if (!tsModule) {
14
16
  tsModule = (0, ensure_typescript_1.ensureTypescript)();
15
17
  tsquery = require('@phenomnomnominal/tsquery').tsquery;
16
18
  }
17
19
  let pathToClientConfigFile;
18
20
  if (options.standalone) {
19
- pathToClientConfigFile = (0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, 'app/app.config.ts');
21
+ pathToClientConfigFile = (0, devkit_1.joinPathFragments)(sourceRoot, 'app/app.config.ts');
20
22
  }
21
23
  else {
22
- pathToClientConfigFile = (0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, 'app/app.module.ts');
24
+ pathToClientConfigFile = (0, devkit_1.joinPathFragments)(sourceRoot, 'app/app.module.ts');
23
25
  if (!tree.exists(pathToClientConfigFile)) {
24
- pathToClientConfigFile = (0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, 'app/app-module.ts');
26
+ pathToClientConfigFile = (0, devkit_1.joinPathFragments)(sourceRoot, 'app/app-module.ts');
25
27
  }
26
28
  }
27
29
  const sourceText = tree.read(pathToClientConfigFile, 'utf-8');
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addServerFile = addServerFile;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
5
6
  const path_1 = require("path");
6
7
  const version_utils_1 = require("../../utils/version-utils");
7
8
  const constants_1 = require("./constants");
@@ -30,7 +31,7 @@ function addServerFile(tree, options) {
30
31
  ? 'application-builder'
31
32
  : 'server-builder');
32
33
  }
33
- const sourceRoot = project.sourceRoot ?? (0, devkit_1.joinPathFragments)(project.root, 'src');
34
+ const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(project, tree);
34
35
  (0, devkit_1.generateFiles)(tree, pathToFiles, angularMajorVersion >= 19 ? sourceRoot : project.root, {
35
36
  ...options,
36
37
  browserDistDirectory,
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateSSRFiles = generateSSRFiles;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
5
6
  const path_1 = require("path");
6
7
  const semver_1 = require("semver");
7
8
  const app_components_info_1 = require("../../utils/app-components-info");
@@ -31,7 +32,7 @@ function generateSSRFiles(tree, options) {
31
32
  else {
32
33
  pathToFiles = (0, path_1.join)(baseFilesPath, 'pre-v19', options.standalone ? 'standalone-src' : 'ngmodule-src');
33
34
  }
34
- const sourceRoot = project.sourceRoot ?? (0, devkit_1.joinPathFragments)(project.root, 'src');
35
+ const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(project, tree);
35
36
  const ssrVersion = (0, version_utils_1.getInstalledPackageVersion)(tree, '@angular/ssr');
36
37
  const cleanedSsrVersion = ssrVersion
37
38
  ? (0, semver_1.clean)(ssrVersion) ?? (0, semver_1.coerce)(ssrVersion).version
@@ -3,6 +3,7 @@ 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 ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
6
7
  const version_utils_1 = require("../../utils/version-utils");
7
8
  const constants_1 = require("./constants");
8
9
  function updateProjectConfigForApplicationBuilder(tree, options) {
@@ -29,7 +30,7 @@ function updateProjectConfigForApplicationBuilder(tree, options) {
29
30
  }
30
31
  }
31
32
  const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
32
- const sourceRoot = project.sourceRoot ?? (0, devkit_1.joinPathFragments)(project.root, 'src');
33
+ const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(project, tree);
33
34
  buildTarget.options ??= {};
34
35
  buildTarget.options.outputPath = outputPath;
35
36
  buildTarget.options.server = (0, devkit_1.joinPathFragments)(sourceRoot, options.main);
@@ -65,7 +66,7 @@ function updateProjectConfigForBrowserBuilder(tree, options) {
65
66
  }
66
67
  }
67
68
  const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
68
- const sourceRoot = projectConfig.sourceRoot ?? (0, devkit_1.joinPathFragments)(projectConfig.root, 'src');
69
+ const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(projectConfig, tree);
69
70
  projectConfig.targets.server = {
70
71
  dependsOn: ['build'],
71
72
  executor: buildTarget.executor.startsWith('@angular-devkit/build-angular:')
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addTailwindConfig = addTailwindConfig;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
5
6
  const path_1 = require("path");
6
7
  function addTailwindConfig(tree, options, project, tailwindVersion) {
7
8
  if (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'tailwind.config.js'))) {
@@ -10,7 +11,7 @@ function addTailwindConfig(tree, options, project, tailwindVersion) {
10
11
  }
11
12
  const filesDir = tailwindVersion === '3' ? 'files/v3' : 'files/v2';
12
13
  (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '..', filesDir), project.root, {
13
- relativeSourceRoot: (0, path_1.relative)(project.root, project.sourceRoot),
14
+ relativeSourceRoot: (0, path_1.relative)(project.root, (0, ts_solution_setup_1.getProjectSourceRoot)(project, tree)),
14
15
  tmpl: '',
15
16
  });
16
17
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateApplicationStyles = updateApplicationStyles;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
5
6
  function updateApplicationStyles(tree, options, project) {
6
7
  let stylesEntryPoint = options.stylesEntryPoint;
7
8
  if (stylesEntryPoint && !tree.exists(stylesEntryPoint)) {
@@ -22,12 +23,13 @@ function updateApplicationStyles(tree, options, project) {
22
23
  ${stylesEntryPointContent}`);
23
24
  }
24
25
  function findStylesEntryPoint(tree, options, project) {
26
+ const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(project, tree);
25
27
  // first check for common names
26
28
  const possibleStylesEntryPoints = [
27
- (0, devkit_1.joinPathFragments)(project.sourceRoot ?? project.root, 'styles.css'),
28
- (0, devkit_1.joinPathFragments)(project.sourceRoot ?? project.root, 'styles.scss'),
29
- (0, devkit_1.joinPathFragments)(project.sourceRoot ?? project.root, 'styles.sass'),
30
- (0, devkit_1.joinPathFragments)(project.sourceRoot ?? project.root, 'styles.less'),
29
+ (0, devkit_1.joinPathFragments)(sourceRoot, 'styles.css'),
30
+ (0, devkit_1.joinPathFragments)(sourceRoot, 'styles.scss'),
31
+ (0, devkit_1.joinPathFragments)(sourceRoot, 'styles.sass'),
32
+ (0, devkit_1.joinPathFragments)(sourceRoot, 'styles.less'),
31
33
  ];
32
34
  let stylesEntryPoint = possibleStylesEntryPoints.find((s) => tree.exists(s));
33
35
  if (stylesEntryPoint) {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAppComponentInfo = getAppComponentInfo;
4
4
  exports.getNxWelcomeComponentInfo = getNxWelcomeComponentInfo;
5
5
  const devkit_1 = require("@nx/devkit");
6
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
6
7
  const node_path_1 = require("node:path");
7
8
  const version_utils_1 = require("./version-utils");
8
9
  function getAppComponentInfo(tree, componentFileSuffix, project) {
@@ -13,18 +14,19 @@ function getNxWelcomeComponentInfo(tree, componentFileSuffix, project) {
13
14
  }
14
15
  // TODO(leo): follow this up and improve it by using static analysis
15
16
  function getComponentInfo(tree, component, componentFileSuffix, project) {
16
- let componentPath = (0, devkit_1.joinPathFragments)(project.sourceRoot, `app/${component}.component.ts`);
17
+ const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(project, tree);
18
+ let componentPath = (0, devkit_1.joinPathFragments)(sourceRoot, `app/${component}.component.ts`);
17
19
  if (!tree.exists(componentPath)) {
18
- componentPath = (0, devkit_1.joinPathFragments)(project.sourceRoot, `app/${component}.ts`);
20
+ componentPath = (0, devkit_1.joinPathFragments)(sourceRoot, `app/${component}.ts`);
19
21
  }
20
22
  if (!tree.exists(componentPath)) {
21
23
  if (componentFileSuffix) {
22
- componentPath = (0, devkit_1.joinPathFragments)(project.sourceRoot, `app/${component}${componentFileSuffix}.ts`);
24
+ componentPath = (0, devkit_1.joinPathFragments)(sourceRoot, `app/${component}${componentFileSuffix}.ts`);
23
25
  }
24
26
  }
25
27
  if (!tree.exists(componentPath)) {
26
28
  const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
27
- componentPath = (0, devkit_1.joinPathFragments)(project.sourceRoot, angularMajorVersion >= 20
29
+ componentPath = (0, devkit_1.joinPathFragments)(sourceRoot, angularMajorVersion >= 20
28
30
  ? `app/${component}.ts`
29
31
  : `app/${component}.component.ts`);
30
32
  }
@@ -7,6 +7,7 @@ exports.generateTestLibrary = generateTestLibrary;
7
7
  exports.createStorybookTestWorkspaceForLib = createStorybookTestWorkspaceForLib;
8
8
  const devkit_1 = require("@nx/devkit");
9
9
  const testing_1 = require("@nx/devkit/testing");
10
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
10
11
  const test_runners_1 = require("../../utils/test-runners");
11
12
  const application_1 = require("../application/application");
12
13
  const component_1 = require("../component/component");
@@ -226,7 +227,7 @@ export class StaticMemberDeclarationsModule {
226
227
  function generateModule(tree, options) {
227
228
  const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
228
229
  if (options.path === undefined) {
229
- const sourceRoot = project.sourceRoot ?? `${project.root}/src`;
230
+ const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(project, tree);
230
231
  const projectDirName = project.projectType === 'application' ? 'app' : 'lib';
231
232
  options.path = `${sourceRoot}/${projectDirName}`;
232
233
  }
@@ -6,6 +6,7 @@ const path_1 = require("path");
6
6
  const version_utils_1 = require("../../generators/utils/version-utils");
7
7
  const targets_1 = require("../../utils/targets");
8
8
  const projects_1 = require("../utils/projects");
9
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
9
10
  const UNIVERSAL_PACKAGES = [
10
11
  '@nguniversal/common',
11
12
  '@nguniversal/express-engine',
@@ -50,7 +51,7 @@ async function default_1(tree) {
50
51
  }
51
52
  // Replace all import specifiers in all files.
52
53
  let hasExpressTokens = false;
53
- const root = project.sourceRoot ?? `${project.root}/src`;
54
+ const root = (0, ts_solution_setup_1.getProjectSourceRoot)(project, tree);
54
55
  const tokensFilePath = `${root}/express.tokens.ts`;
55
56
  (0, devkit_1.visitNotIgnoredFiles)(tree, root, (path) => {
56
57
  if (!path.endsWith('.ts') || path.endsWith('.d.ts')) {
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export declare const angularCliVersion = "~20.1.0";
3
+ export default function (tree: Tree): Promise<void>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.angularCliVersion = void 0;
4
+ exports.default = default_1;
5
+ const devkit_1 = require("@nx/devkit");
6
+ exports.angularCliVersion = '~20.1.0';
7
+ async function default_1(tree) {
8
+ let shouldFormat = false;
9
+ (0, devkit_1.updateJson)(tree, 'package.json', (json) => {
10
+ if (json.devDependencies?.['@angular/cli']) {
11
+ json.devDependencies['@angular/cli'] = exports.angularCliVersion;
12
+ shouldFormat = true;
13
+ }
14
+ else if (json.dependencies?.['@angular/cli']) {
15
+ json.dependencies['@angular/cli'] = exports.angularCliVersion;
16
+ shouldFormat = true;
17
+ }
18
+ return json;
19
+ });
20
+ if (shouldFormat) {
21
+ await (0, devkit_1.formatFiles)(tree);
22
+ }
23
+ }
@@ -26,6 +26,7 @@ exports.backwardCompatibleVersions = {
26
26
  postcssUrlVersion: '~10.1.3',
27
27
  autoprefixerVersion: '^10.4.0',
28
28
  tsNodeVersion: '10.9.1',
29
+ lessVersion: '^4.3.0',
29
30
  jestPresetAngularVersion: '~14.1.0',
30
31
  typesNodeVersion: '18.16.9',
31
32
  jasmineMarblesVersion: '^0.9.2',
@@ -56,6 +57,7 @@ exports.backwardCompatibleVersions = {
56
57
  postcssUrlVersion: '~10.1.3',
57
58
  autoprefixerVersion: '^10.4.0',
58
59
  tsNodeVersion: '10.9.1',
60
+ lessVersion: '^4.3.0',
59
61
  jestPresetAngularVersion: '~14.4.0',
60
62
  typesNodeVersion: '18.16.9',
61
63
  jasmineMarblesVersion: '^0.9.2',
@@ -26,6 +26,7 @@ exports.getTsSourceFile = getTsSourceFile;
26
26
  const devkit_1 = require("@nx/devkit");
27
27
  const js_1 = require("@nx/js");
28
28
  const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
29
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
29
30
  const path_1 = require("path");
30
31
  const angular_version_utils_1 = require("../../executors/utilities/angular-version-utils");
31
32
  const version_utils_1 = require("../../generators/utils/version-utils");
@@ -451,7 +452,7 @@ function isNgStandaloneApp(tree, projectName) {
451
452
  hasMainFile = true;
452
453
  }
453
454
  else {
454
- const sourceRoot = project.sourceRoot ?? (0, devkit_1.joinPathFragments)(project.root, 'src');
455
+ const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(project, tree);
455
456
  mainFile = (0, devkit_1.joinPathFragments)(sourceRoot, 'main.ts');
456
457
  hasMainFile = tree.exists(mainFile);
457
458
  }
@@ -560,7 +561,7 @@ function readBootstrapInfo(host, app) {
560
561
  config.targets.build.options?.main ??
561
562
  config.targets.build.options?.browser;
562
563
  if (!mainPath) {
563
- const sourceRoot = config.sourceRoot ?? (0, devkit_1.joinPathFragments)(config.root, 'src');
564
+ const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(config, host);
564
565
  mainPath = (0, devkit_1.joinPathFragments)(sourceRoot, 'main.ts');
565
566
  }
566
567
  }
@@ -1,7 +1,7 @@
1
1
  export declare const nxVersion: any;
2
- export declare const angularVersion = "~20.0.0";
3
- export declare const angularDevkitVersion = "~20.0.0";
4
- export declare const ngPackagrVersion = "~20.0.0";
2
+ export declare const angularVersion = "~20.1.0";
3
+ export declare const angularDevkitVersion = "~20.1.0";
4
+ export declare const ngPackagrVersion = "~20.1.0";
5
5
  export declare const angularRspackVersion = "^21.1.0";
6
6
  export declare const ngrxVersion = "^19.0.0";
7
7
  export declare const rxjsVersion = "~7.8.0";
@@ -23,6 +23,7 @@ export declare const postcssVersion = "^8.4.5";
23
23
  export declare const postcssUrlVersion = "~10.1.3";
24
24
  export declare const autoprefixerVersion = "^10.4.0";
25
25
  export declare const tsNodeVersion = "10.9.1";
26
+ export declare const lessVersion = "^4.3.0";
26
27
  export declare const jestPresetAngularVersion = "~14.6.0";
27
28
  export declare const typesNodeVersion = "18.16.9";
28
29
  export declare const jasmineMarblesVersion = "^0.9.2";
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jsoncEslintParserVersion = exports.jasmineMarblesVersion = exports.typesNodeVersion = exports.jestPresetAngularVersion = exports.tsNodeVersion = exports.autoprefixerVersion = exports.postcssUrlVersion = exports.postcssVersion = exports.tailwindVersion = exports.typescriptEslintVersion = exports.angularEslintVersion = exports.webpackMergeVersion = exports.moduleFederationEnhancedVersion = exports.moduleFederationNodeVersion = exports.browserSyncVersion = exports.typesExpressVersion = exports.expressVersion = exports.typesCorsVersion = exports.corsVersion = exports.tsLibVersion = exports.angularJsVersion = exports.zoneJsVersion = exports.rxjsVersion = exports.ngrxVersion = exports.angularRspackVersion = exports.ngPackagrVersion = exports.angularDevkitVersion = exports.angularVersion = exports.nxVersion = void 0;
3
+ exports.jsoncEslintParserVersion = exports.jasmineMarblesVersion = exports.typesNodeVersion = exports.jestPresetAngularVersion = exports.lessVersion = exports.tsNodeVersion = exports.autoprefixerVersion = exports.postcssUrlVersion = exports.postcssVersion = exports.tailwindVersion = exports.typescriptEslintVersion = exports.angularEslintVersion = exports.webpackMergeVersion = exports.moduleFederationEnhancedVersion = exports.moduleFederationNodeVersion = exports.browserSyncVersion = exports.typesExpressVersion = exports.expressVersion = exports.typesCorsVersion = exports.corsVersion = exports.tsLibVersion = exports.angularJsVersion = exports.zoneJsVersion = exports.rxjsVersion = exports.ngrxVersion = exports.angularRspackVersion = exports.ngPackagrVersion = exports.angularDevkitVersion = exports.angularVersion = exports.nxVersion = void 0;
4
4
  exports.nxVersion = require('../../package.json').version;
5
- exports.angularVersion = '~20.0.0';
6
- exports.angularDevkitVersion = '~20.0.0';
7
- exports.ngPackagrVersion = '~20.0.0';
5
+ exports.angularVersion = '~20.1.0';
6
+ exports.angularDevkitVersion = '~20.1.0';
7
+ exports.ngPackagrVersion = '~20.1.0';
8
8
  exports.angularRspackVersion = '^21.1.0';
9
9
  exports.ngrxVersion = '^19.0.0';
10
10
  exports.rxjsVersion = '~7.8.0';
@@ -26,6 +26,7 @@ exports.postcssVersion = '^8.4.5';
26
26
  exports.postcssUrlVersion = '~10.1.3';
27
27
  exports.autoprefixerVersion = '^10.4.0';
28
28
  exports.tsNodeVersion = '10.9.1';
29
+ exports.lessVersion = '^4.3.0';
29
30
  exports.jestPresetAngularVersion = '~14.6.0';
30
31
  exports.typesNodeVersion = '18.16.9';
31
32
  exports.jasmineMarblesVersion = '^0.9.2';