@nx/angular 19.1.0-beta.1 → 19.1.0-beta.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. package/executors.json +1 -1
  2. package/migrations.json +82 -0
  3. package/package.json +14 -13
  4. package/src/builders/dev-server/dev-server.impl.js +1 -1
  5. package/src/builders/dev-server/schema.json +1 -1
  6. package/src/builders/module-federation-dev-ssr/module-federation-dev-ssr.impl.js +4 -1
  7. package/src/builders/utilities/module-federation.d.ts +2 -1
  8. package/src/builders/utilities/module-federation.js +17 -3
  9. package/src/builders/webpack-browser/schema.json +4 -3
  10. package/src/builders/webpack-browser/webpack-browser.impl.js +1 -1
  11. package/src/builders/webpack-server/schema.json +7 -6
  12. package/src/builders/webpack-server/webpack-server.impl.js +3 -5
  13. package/src/executors/application/application.impl.d.ts +2 -1
  14. package/src/executors/application/application.impl.js +2 -2
  15. package/src/executors/application/schema.json +4 -3
  16. package/src/executors/browser-esbuild/browser-esbuild.impl.d.ts +2 -7
  17. package/src/executors/browser-esbuild/browser-esbuild.impl.js +2 -2
  18. package/src/executors/browser-esbuild/schema.json +4 -3
  19. package/src/executors/extract-i18n/extract-i18n.impl.js +2 -2
  20. package/src/executors/module-federation-dev-server/lib/start-static-remotes-file-server.js +2 -1
  21. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +8 -4
  22. package/src/executors/module-federation-dev-server/schema.json +1 -1
  23. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-packagr.js +6 -6
  24. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ng-package/entry-point/compile-ngc.transform.js +3 -2
  25. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ng-package/entry-point/write-package.transform.js +2 -1
  26. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ng-package/options.di.js +2 -1
  27. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ngc/compile-source-files.d.ts +1 -2
  28. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ngc/compile-source-files.js +5 -4
  29. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/styles/stylesheet-processor.js +11 -11
  30. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/v17+/ng-package/entry-point/write-package.transform.js +2 -1
  31. package/src/executors/ng-packagr-lite/schema.json +1 -1
  32. package/src/executors/package/ng-packagr-adjustments/ng-package/entry-point/compile-ngc.transform.js +5 -4
  33. package/src/executors/package/ng-packagr-adjustments/ng-package/options.di.js +2 -1
  34. package/src/executors/package/ng-packagr-adjustments/ng-packagr.js +4 -4
  35. package/src/executors/package/ng-packagr-adjustments/ngc/compile-source-files.d.ts +1 -2
  36. package/src/executors/package/ng-packagr-adjustments/ngc/compile-source-files.js +5 -4
  37. package/src/executors/package/ng-packagr-adjustments/styles/stylesheet-processor.js +11 -11
  38. package/src/executors/utilities/esbuild-extensions.d.ts +2 -4
  39. package/src/executors/utilities/module-loader.d.ts +1 -2
  40. package/src/executors/utilities/ng-packagr/stylesheet-processor.js +22 -8
  41. package/src/executors/utilities/typescript.d.ts +1 -2
  42. package/src/executors/utilities/typescript.js +4 -3
  43. package/src/generators/add-linting/lib/create-eslint-configuration.d.ts +2 -2
  44. package/src/generators/add-linting/schema.json +1 -1
  45. package/src/generators/application/files/base-pre18/src/favicon.ico +0 -0
  46. package/src/generators/application/files/ng-module/src/main.ts__tpl__ +3 -1
  47. package/src/generators/application/files/standalone-components/src/app/app.config.ts__tpl__ +2 -2
  48. package/src/generators/application/lib/add-linting.js +2 -1
  49. package/src/generators/application/lib/create-files.js +7 -0
  50. package/src/generators/application/lib/create-project.js +12 -5
  51. package/src/generators/component-test/component-test.js +1 -1
  52. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +3 -3
  53. package/src/generators/federate-module/lib/add-remote.js +2 -1
  54. package/src/generators/host/host.js +3 -2
  55. package/src/generators/library/library.js +4 -3
  56. package/src/generators/ng-add/migrators/builders/angular-devkit-karma.migrator.js +3 -2
  57. package/src/generators/ng-add/migrators/migrator.d.ts +1 -1
  58. package/src/generators/ng-add/migrators/migrator.js +7 -7
  59. package/src/generators/ng-add/migrators/projects/app.migrator.js +2 -2
  60. package/src/generators/ng-add/migrators/projects/e2e.migrator.js +1 -1
  61. package/src/generators/ng-add/utilities/validation-logging.js +2 -1
  62. package/src/generators/ngrx-root-store/ngrx-root-store.js +2 -1
  63. package/src/generators/setup-mf/lib/add-remote-to-host.js +13 -4
  64. package/src/generators/setup-mf/lib/fix-bootstrap.d.ts +1 -1
  65. package/src/generators/setup-mf/lib/fix-bootstrap.js +12 -5
  66. package/src/generators/setup-mf/lib/setup-host-if-dynamic.js +5 -1
  67. package/src/generators/setup-mf/setup-mf.js +1 -1
  68. package/src/generators/setup-ssr/files/server/application-builder/__serverFileName__ +4 -3
  69. package/src/generators/setup-ssr/files/server/server-builder/v17+/__serverFileName__ +4 -3
  70. package/src/generators/setup-ssr/lib/add-dependencies.js +2 -1
  71. package/src/generators/setup-ssr/lib/generate-files.js +1 -7
  72. package/src/generators/setup-ssr/lib/index.d.ts +0 -1
  73. package/src/generators/setup-ssr/lib/index.js +0 -1
  74. package/src/generators/setup-ssr/lib/validate-options.js +0 -13
  75. package/src/generators/setup-ssr/schema.json +4 -3
  76. package/src/generators/setup-ssr/setup-ssr.js +0 -3
  77. package/src/generators/stories/stories.js +3 -2
  78. package/src/generators/storybook-configuration/lib/generate-stories.js +1 -1
  79. package/src/generators/utils/storybook-ast/tree-utilities.js +2 -1
  80. package/src/generators/utils/version-utils.js +4 -3
  81. package/src/migrations/update-15-2-0/remove-browserlist-config.js +1 -1
  82. package/src/migrations/update-15-2-0/remove-platform-server-exports.js +2 -1
  83. package/src/migrations/update-15-2-0/update-karma-main-file.js +2 -1
  84. package/src/migrations/update-16-1-0/remove-render-module-platform-server-exports.js +2 -1
  85. package/src/migrations/update-19-1-0/update-angular-cli.d.ts +3 -0
  86. package/src/migrations/update-19-1-0/update-angular-cli.js +23 -0
  87. package/src/utils/backward-compatible-versions.d.ts +10 -5
  88. package/src/utils/backward-compatible-versions.js +18 -19
  89. package/src/utils/file-change-recorder.js +2 -1
  90. package/src/utils/mf/with-module-federation.js +3 -2
  91. package/src/utils/version-utils.d.ts +2 -2
  92. package/src/utils/version-utils.js +2 -1
  93. package/src/utils/versions.d.ts +4 -4
  94. package/src/utils/versions.js +4 -4
  95. package/index.js +0 -8
  96. package/mf/index.js +0 -7
  97. package/mf/mf.js +0 -53
  98. package/src/builders/webpack-server/validate-options.d.ts +0 -2
  99. package/src/builders/webpack-server/validate-options.js +0 -33
  100. package/src/executors/utilities/ng-compiler-cli.d.ts +0 -1
  101. package/src/executors/utilities/ng-compiler-cli.js +0 -8
  102. package/src/generators/setup-ssr/files/ngmodule/pre-v15-2/src/main.ts__tpl__ +0 -14
  103. package/src/generators/setup-ssr/lib/update-app-module.d.ts +0 -3
  104. package/src/generators/setup-ssr/lib/update-app-module.js +0 -27
  105. package/src/runtime/nx/data-persistence.js +0 -350
  106. package/testing/index.js +0 -6
  107. package/testing/src/testing-utils.js +0 -40
  108. /package/src/generators/application/files/{base/src → base-18+/public}/favicon.ico +0 -0
  109. /package/src/generators/application/files/{base → base-pre18}/src/assets/.gitkeep__tpl__ +0 -0
  110. /package/src/generators/setup-ssr/files/ngmodule/{base/src → src}/__main__ +0 -0
  111. /package/src/generators/setup-ssr/files/ngmodule/{base/src → src}/app/__rootModuleFileName__ +0 -0
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addRemote = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
5
6
  const test_runners_1 = require("../../../utils/test-runners");
6
- const remote_1 = require("../../remote/remote");
7
+ const remote_1 = tslib_1.__importDefault(require("../../remote/remote"));
7
8
  const check_remote_exists_1 = require("./check-remote-exists");
8
9
  async function addRemote(tree, schema) {
9
10
  const tasks = [];
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.hostInternal = exports.host = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const devkit_1 = require("@nx/devkit");
5
6
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
7
  const test_runners_1 = require("../../utils/test-runners");
7
- const application_1 = require("../application/application");
8
- const remote_1 = require("../remote/remote");
8
+ const application_1 = tslib_1.__importDefault(require("../application/application"));
9
+ const remote_1 = tslib_1.__importDefault(require("../remote/remote"));
9
10
  const setup_mf_1 = require("../setup-mf/setup-mf");
10
11
  const lib_1 = require("./lib");
11
12
  const add_mf_env_to_inputs_1 = require("../utils/add-mf-env-to-inputs");
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.libraryGeneratorInternal = exports.libraryGenerator = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const devkit_1 = require("@nx/devkit");
5
6
  const eslint_1 = require("@nx/eslint");
6
7
  const js_1 = require("@nx/js");
7
- const init_1 = require("../../generators/init/init");
8
- const add_linting_1 = require("../add-linting/add-linting");
9
- const setup_tailwind_1 = require("../setup-tailwind/setup-tailwind");
8
+ const init_1 = tslib_1.__importDefault(require("../../generators/init/init"));
9
+ const add_linting_1 = tslib_1.__importDefault(require("../add-linting/add-linting"));
10
+ const setup_tailwind_1 = tslib_1.__importDefault(require("../setup-tailwind/setup-tailwind"));
10
11
  const version_utils_1 = require("../utils/version-utils");
11
12
  const dependencies_1 = require("../utils/dependencies");
12
13
  const add_module_1 = require("./lib/add-module");
@@ -41,8 +41,9 @@ class AngularDevkitKarmaMigrator extends builder_migrator_1.BuilderMigrator {
41
41
  target.options.main =
42
42
  target.options.main && this.convertAsset(target.options.main);
43
43
  target.options.polyfills = Array.isArray(target.options.polyfills)
44
- ? target.options.polyfills.map((p) => this.convertAsset(p))
45
- : target.options.polyfills && this.convertAsset(target.options.polyfills);
44
+ ? target.options.polyfills.map((p) => this.convertSourceRootPath(p))
45
+ : target.options.polyfills &&
46
+ this.convertSourceRootPath(target.options.polyfills);
46
47
  target.options.tsConfig =
47
48
  target.options.tsConfig &&
48
49
  (0, devkit_1.joinPathFragments)(this.project.newRoot, (0, path_1.basename)(target.options.tsConfig));
@@ -12,12 +12,12 @@ export declare abstract class Migrator {
12
12
  abstract validate(): ValidationResult;
13
13
  protected convertAsset(asset: string | any): string | any;
14
14
  protected convertRootPath(originalPath: string): string;
15
+ protected convertSourceRootPath(originalPath: string): string;
15
16
  protected moveFile(from: string, to: string, required?: boolean): void;
16
17
  protected moveFilePathsFromTargetToProjectRoot(target: TargetConfiguration, options: string[]): void;
17
18
  protected moveProjectRootFile(filePath: string, isRequired?: boolean): void;
18
19
  protected updateCacheableOperations(targetNames: string[]): void;
19
20
  protected updateTsConfigFile(tsConfigPath: string, rootTsConfigFile: string, projectOffsetFromRoot: string): void;
20
- private convertSourceRootPath;
21
21
  private getTargetValuesForOption;
22
22
  private getValueForOption;
23
23
  }
@@ -12,10 +12,10 @@ class Migrator {
12
12
  }
13
13
  convertAsset(asset) {
14
14
  if (typeof asset === 'string') {
15
- return this.convertSourceRootPath(asset);
15
+ return this.convertRootPath(asset);
16
16
  }
17
17
  else {
18
- return { ...asset, input: this.convertSourceRootPath(asset.input) };
18
+ return { ...asset, input: this.convertRootPath(asset.input) };
19
19
  }
20
20
  }
21
21
  convertRootPath(originalPath) {
@@ -23,6 +23,11 @@ class Migrator {
23
23
  ? (0, devkit_1.joinPathFragments)(this.project.newRoot, originalPath.replace(this.project.oldRoot, ''))
24
24
  : originalPath;
25
25
  }
26
+ convertSourceRootPath(originalPath) {
27
+ return originalPath?.startsWith(this.project.oldSourceRoot)
28
+ ? (0, devkit_1.joinPathFragments)(this.project.newSourceRoot, originalPath.replace(this.project.oldSourceRoot, ''))
29
+ : originalPath;
30
+ }
26
31
  moveFile(from, to, required = true) {
27
32
  if (!this.tree.exists(from)) {
28
33
  if (required) {
@@ -78,11 +83,6 @@ class Migrator {
78
83
  return json;
79
84
  });
80
85
  }
81
- convertSourceRootPath(originalPath) {
82
- return originalPath?.startsWith(this.project.oldSourceRoot)
83
- ? (0, devkit_1.joinPathFragments)(this.project.newSourceRoot, originalPath.replace(this.project.oldSourceRoot, ''))
84
- : originalPath;
85
- }
86
86
  getTargetValuesForOption(target, optionPath) {
87
87
  const values = new Set();
88
88
  const value = this.getValueForOption(target.options, optionPath);
@@ -160,8 +160,8 @@ class AppMigrator extends project_migrator_1.ProjectMigrator {
160
160
  buildOptions.polyfills =
161
161
  buildOptions.polyfills &&
162
162
  (Array.isArray(buildOptions.polyfills)
163
- ? buildOptions.polyfills.map((asset) => this.convertAsset(asset))
164
- : this.convertAsset(buildOptions.polyfills));
163
+ ? buildOptions.polyfills.map((asset) => this.convertSourceRootPath(asset))
164
+ : this.convertSourceRootPath(buildOptions.polyfills));
165
165
  buildOptions.tsConfig =
166
166
  buildOptions.tsConfig &&
167
167
  (0, devkit_1.joinPathFragments)(this.project.newRoot, (0, path_1.basename)(buildOptions.tsConfig));
@@ -237,7 +237,7 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
237
237
  const nxJson = (0, devkit_1.readNxJson)(this.tree) ?? {};
238
238
  const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
239
239
  nxJson.useInferencePlugins !== false;
240
- const { configurationGenerator } = await Promise.resolve().then(() => require('@nx/cypress'));
240
+ const { configurationGenerator } = (require('@nx/cypress'));
241
241
  await configurationGenerator(this.tree, {
242
242
  project: this.project.name,
243
243
  linter: this.isProjectUsingEsLint ? eslint_1.Linter.EsLint : eslint_1.Linter.None,
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getProjectValidationResultMessage = exports.arrayToString = void 0;
4
- const chalk = require("chalk");
4
+ const tslib_1 = require("tslib");
5
+ const chalk = tslib_1.__importStar(require("chalk"));
5
6
  function arrayToString(array) {
6
7
  if (array.length === 0) {
7
8
  return '';
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ngrxRootStoreGenerator = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const devkit_1 = require("@nx/devkit");
5
6
  const lib_1 = require("./lib");
6
- const ngrx_feature_store_1 = require("../ngrx-feature-store/ngrx-feature-store");
7
+ const ngrx_feature_store_1 = tslib_1.__importDefault(require("../ngrx-feature-store/ngrx-feature-store"));
7
8
  async function ngrxRootStoreGenerator(tree, schema) {
8
9
  (0, lib_1.validateOptions)(tree, schema);
9
10
  const options = (0, lib_1.normalizeOptions)(tree, schema);
@@ -18,8 +18,8 @@ exports.checkIsCommaNeeded = checkIsCommaNeeded;
18
18
  function addRemoteToHost(tree, options) {
19
19
  if (options.host) {
20
20
  const hostProject = (0, devkit_1.readProjectConfiguration)(tree, options.host);
21
- const pathToMFManifest = (0, devkit_1.joinPathFragments)(hostProject.sourceRoot, 'assets/module-federation.manifest.json');
22
- const hostFederationType = determineHostFederationType(tree, pathToMFManifest);
21
+ const pathToMFManifest = getDynamicManifestFile(tree, hostProject);
22
+ const hostFederationType = !!pathToMFManifest ? 'dynamic' : 'static';
23
23
  const isHostUsingTypescriptConfig = tree.exists((0, devkit_1.joinPathFragments)(hostProject.root, 'module-federation.config.ts'));
24
24
  if (hostFederationType === 'static') {
25
25
  addRemoteToStaticHost(tree, options, hostProject, isHostUsingTypescriptConfig);
@@ -31,8 +31,17 @@ function addRemoteToHost(tree, options) {
31
31
  }
32
32
  }
33
33
  exports.addRemoteToHost = addRemoteToHost;
34
- function determineHostFederationType(tree, pathToMfManifest) {
35
- return tree.exists(pathToMfManifest) ? 'dynamic' : 'static';
34
+ function getDynamicManifestFile(tree, project) {
35
+ // {sourceRoot}/assets/module-federation.manifest.json was the generated
36
+ // path for the manifest file in the past. We now generate the manifest
37
+ // file at {root}/public/module-federation.manifest.json. This check
38
+ // ensures that we can still support the old path for backwards
39
+ // compatibility since old projects may still have the manifest file
40
+ // at the old path.
41
+ return [
42
+ (0, devkit_1.joinPathFragments)(project.root, 'public/module-federation.manifest.json'),
43
+ (0, devkit_1.joinPathFragments)(project.sourceRoot, 'assets/module-federation.manifest.json'),
44
+ ].find((path) => tree.exists(path));
36
45
  }
37
46
  function addRemoteToStaticHost(tree, options, hostProject, isHostUsingTypescript) {
38
47
  const hostMFConfigPath = (0, devkit_1.joinPathFragments)(hostProject.root, isHostUsingTypescript
@@ -1,3 +1,3 @@
1
- import type { Tree } from '@nx/devkit';
1
+ import { type Tree } from '@nx/devkit';
2
2
  import type { Schema } from '../schema';
3
3
  export declare function fixBootstrap(tree: Tree, appRoot: string, options: Schema): void;
@@ -12,15 +12,22 @@ function fixBootstrap(tree, appRoot, options) {
12
12
  tree.write((0, devkit_1.joinPathFragments)(appRoot, 'src/bootstrap.ts'), bootstrapCode);
13
13
  }
14
14
  const bootstrapImportCode = `import('./bootstrap').catch(err => console.error(err))`;
15
- const fetchMFManifestCode = `import { setRemoteDefinitions } from '@nx/angular/mf';
15
+ if (options.mfType === 'remote' || options.federationType === 'static') {
16
+ tree.write(mainFilePath, `${bootstrapImportCode};`);
17
+ }
18
+ else {
19
+ let manifestPath = '/assets/module-federation.manifest.json';
20
+ if (tree.exists((0, devkit_1.joinPathFragments)(appRoot, 'public/module-federation.manifest.json'))) {
21
+ manifestPath = '/module-federation.manifest.json';
22
+ }
23
+ const fetchMFManifestCode = `import { setRemoteDefinitions } from '@nx/angular/mf';
16
24
 
17
- fetch('/assets/module-federation.manifest.json')
25
+ fetch('${manifestPath}')
18
26
  .then((res) => res.json())
19
27
  .then(definitions => setRemoteDefinitions(definitions))
20
28
  .then(() => ${bootstrapImportCode});`;
21
- tree.write(mainFilePath, options.mfType === 'host' && options.federationType === 'dynamic'
22
- ? fetchMFManifestCode
23
- : `${bootstrapImportCode};`);
29
+ tree.write(mainFilePath, fetchMFManifestCode);
30
+ }
24
31
  }
25
32
  exports.fixBootstrap = fixBootstrap;
26
33
  const standaloneBootstrapCode = () => `import { bootstrapApplication } from '@angular/platform-browser';
@@ -2,12 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setupHostIfDynamic = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const version_utils_1 = require("../../utils/version-utils");
5
6
  function setupHostIfDynamic(tree, options) {
6
7
  if (options.federationType === 'static') {
7
8
  return;
8
9
  }
10
+ const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
9
11
  const project = (0, devkit_1.readProjectConfiguration)(tree, options.appName);
10
- const pathToMFManifest = (0, devkit_1.joinPathFragments)(project.sourceRoot, 'assets/module-federation.manifest.json');
12
+ const pathToMFManifest = angularMajorVersion >= 18
13
+ ? (0, devkit_1.joinPathFragments)(project.root, 'public/module-federation.manifest.json')
14
+ : (0, devkit_1.joinPathFragments)(project.sourceRoot, 'assets/module-federation.manifest.json');
11
15
  if (!tree.exists(pathToMFManifest)) {
12
16
  tree.write(pathToMFManifest, '{}');
13
17
  }
@@ -27,7 +27,6 @@ async function setupMf(tree, rawOptions) {
27
27
  (0, lib_1.changeBuildTarget)(tree, options);
28
28
  (0, lib_1.updateTsConfig)(tree, options);
29
29
  (0, lib_1.setupServeTarget)(tree, options);
30
- (0, lib_1.fixBootstrap)(tree, projectConfig.root, options);
31
30
  if (options.mfType === 'host') {
32
31
  (0, lib_1.setupHostIfDynamic)(tree, options);
33
32
  (0, lib_1.updateHostAppRoutes)(tree, options);
@@ -43,6 +42,7 @@ async function setupMf(tree, rawOptions) {
43
42
  installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nx/webpack': versions_1.nxVersion });
44
43
  }
45
44
  }
45
+ (0, lib_1.fixBootstrap)(tree, projectConfig.root, options);
46
46
  if (!options.skipE2E) {
47
47
  (0, lib_1.addCypressOnErrorWorkaround)(tree, options);
48
48
  }
@@ -20,12 +20,13 @@ export function app(): express.Express {
20
20
  // Example Express Rest API endpoints
21
21
  // server.get('/api/**', (req, res) => { });
22
22
  // Serve static files from /browser
23
- server.get('*.*', express.static(browserDistFolder, {
24
- maxAge: '1y'
23
+ server.get('**', express.static(browserDistFolder, {
24
+ maxAge: '1y',
25
+ index: 'index.html',
25
26
  }));
26
27
 
27
28
  // All regular routes use the Angular engine
28
- server.get('*', (req, res, next) => {
29
+ server.get('**', (req, res, next) => {
29
30
  const { protocol, originalUrl, baseUrl, headers } = req;
30
31
 
31
32
  commonEngine
@@ -23,12 +23,13 @@ export function app(): express.Express {
23
23
  // Example Express Rest API endpoints
24
24
  // server.get('/api/**', (req, res) => { });
25
25
  // Serve static files from /browser
26
- server.get('*.*', express.static(distFolder, {
27
- maxAge: '1y'
26
+ server.get('**', express.static(distFolder, {
27
+ maxAge: '1y',
28
+ index: 'index.html'
28
29
  }));
29
30
 
30
31
  // All regular routes use the Angular engine
31
- server.get('*', (req, res, next) => {
32
+ server.get('**', (req, res, next) => {
32
33
  const { protocol, originalUrl, baseUrl, headers } = req;
33
34
 
34
35
  commonEngine
@@ -26,7 +26,8 @@ function addDependencies(tree, isUsingApplicationBuilder) {
26
26
  else {
27
27
  dependencies['@nguniversal/express-engine'] =
28
28
  (0, version_utils_1.getInstalledPackageVersionInfo)(tree, '@nguniversal/express-engine')
29
- ?.version ?? pkgVersions.ngUniversalVersion;
29
+ ?.version ??
30
+ pkgVersions.ngUniversalVersion;
30
31
  devDependencies['@nguniversal/builders'] =
31
32
  (0, version_utils_1.getInstalledPackageVersionInfo)(tree, '@nguniversal/builders')?.version ??
32
33
  pkgVersions.ngUniversalVersion;
@@ -2,8 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateSSRFiles = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const semver_1 = require("semver");
6
- const version_utils_1 = require("../../utils/version-utils");
7
5
  function generateSSRFiles(tree, schema, isUsingApplicationBuilder) {
8
6
  const { root: projectRoot, targets } = (0, devkit_1.readProjectConfiguration)(tree, schema.project);
9
7
  if (targets.server ||
@@ -12,15 +10,11 @@ function generateSSRFiles(tree, schema, isUsingApplicationBuilder) {
12
10
  return;
13
11
  }
14
12
  const pathToFiles = (0, devkit_1.joinPathFragments)(__dirname, '..', 'files');
15
- const { version: angularVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
16
13
  if (schema.standalone) {
17
14
  (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(pathToFiles, 'standalone'), projectRoot, { ...schema, tpl: '' });
18
15
  }
19
16
  else {
20
- (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(pathToFiles, 'ngmodule', 'base'), projectRoot, { ...schema, tpl: '' });
21
- if ((0, semver_1.lt)(angularVersion, '15.2.0')) {
22
- (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(pathToFiles, 'ngmodule', 'pre-v15-2'), projectRoot, { ...schema, tpl: '' });
23
- }
17
+ (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(pathToFiles, 'ngmodule'), projectRoot, { ...schema, tpl: '' });
24
18
  }
25
19
  }
26
20
  exports.generateSSRFiles = generateSSRFiles;
@@ -3,7 +3,6 @@ export * from './add-server-file';
3
3
  export * from './generate-files';
4
4
  export * from './generate-server-ts-config';
5
5
  export * from './normalize-options';
6
- export * from './update-app-module';
7
6
  export * from './update-project-config';
8
7
  export * from './validate-options';
9
8
  export * from './add-hydration';
@@ -6,7 +6,6 @@ tslib_1.__exportStar(require("./add-server-file"), exports);
6
6
  tslib_1.__exportStar(require("./generate-files"), exports);
7
7
  tslib_1.__exportStar(require("./generate-server-ts-config"), exports);
8
8
  tslib_1.__exportStar(require("./normalize-options"), exports);
9
- tslib_1.__exportStar(require("./update-app-module"), exports);
10
9
  tslib_1.__exportStar(require("./update-project-config"), exports);
11
10
  tslib_1.__exportStar(require("./validate-options"), exports);
12
11
  tslib_1.__exportStar(require("./add-hydration"), exports);
@@ -3,12 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateOptions = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const validations_1 = require("../../utils/validations");
6
- const version_utils_1 = require("../../utils/version-utils");
7
- const semver_1 = require("semver");
8
6
  function validateOptions(tree, options) {
9
7
  validateProject(tree, options.project);
10
8
  validateBuildTarget(tree, options.project);
11
- validateHydrationOption(tree, options.hydration);
12
9
  }
13
10
  exports.validateOptions = validateOptions;
14
11
  function validateProject(tree, project) {
@@ -24,13 +21,3 @@ function validateBuildTarget(tree, project) {
24
21
  throw new Error(`The "${project}" project does not have a "build" target. Please add a "build" target.`);
25
22
  }
26
23
  }
27
- function validateHydrationOption(tree, hydration) {
28
- if (!hydration) {
29
- return;
30
- }
31
- const installedAngularVersion = (0, version_utils_1.getInstalledAngularVersionInfo)(tree).version;
32
- if ((0, semver_1.lt)(installedAngularVersion, '16.0.0')) {
33
- throw new Error((0, devkit_1.stripIndents) `The "hydration" option is only supported in Angular >= 16.0.0. You are currently using "${installedAngularVersion}".
34
- You can resolve this error by removing the "hydration" option or by migrating to Angular 16.0.0.`);
35
- }
36
- }
@@ -19,8 +19,9 @@
19
19
  "appId": {
20
20
  "type": "string",
21
21
  "format": "html-selector",
22
- "description": "The `appId` to use with `withServerTransition`. _Note: This is only used in Angular versions <16.0.0. It's deprecated since Angular 16 and not supported since Angular 17._",
23
- "default": "serverApp"
22
+ "description": "The `appId` to use with `withServerTransition`.",
23
+ "default": "serverApp",
24
+ "x-deprecated": "This is deprecated and ignored since Angular 16 and not supported since Angular 17."
24
25
  },
25
26
  "main": {
26
27
  "type": "string",
@@ -55,7 +56,7 @@
55
56
  },
56
57
  "hydration": {
57
58
  "type": "boolean",
58
- "description": "Set up Hydration for the SSR application. It defaults to `true` for Angular versions >= 17.0.0. Otherwise, it defaults to `false`. _Note: This is only supported in Angular versions >= 16.0.0_."
59
+ "description": "Set up Hydration for the SSR application. It defaults to `true` for Angular versions >= 17.0.0. Otherwise, it defaults to `false`."
59
60
  },
60
61
  "skipFormat": {
61
62
  "type": "boolean",
@@ -14,9 +14,6 @@ async function setupSsr(tree, schema) {
14
14
  (0, lib_1.addDependencies)(tree, isUsingApplicationBuilder);
15
15
  }
16
16
  (0, lib_1.generateSSRFiles)(tree, options, isUsingApplicationBuilder);
17
- if (!options.standalone) {
18
- (0, lib_1.updateAppModule)(tree, options);
19
- }
20
17
  if (options.hydration) {
21
18
  (0, lib_1.addHydration)(tree, options);
22
19
  }
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.angularStoriesGenerator = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const devkit_1 = require("@nx/devkit");
5
- const component_cypress_spec_1 = require("../component-cypress-spec/component-cypress-spec");
6
- const component_story_1 = require("../component-story/component-story");
6
+ const component_cypress_spec_1 = tslib_1.__importDefault(require("../component-cypress-spec/component-cypress-spec"));
7
+ const component_story_1 = tslib_1.__importDefault(require("../component-story/component-story"));
7
8
  const component_info_1 = require("../utils/storybook-ast/component-info");
8
9
  const entry_point_1 = require("../utils/storybook-ast/entry-point");
9
10
  const get_e2e_project_1 = require("./lib/get-e2e-project");
@@ -7,7 +7,7 @@ const stories_1 = require("../../stories/stories");
7
7
  async function generateStories(tree, options) {
8
8
  const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
9
9
  (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
10
- const { getE2eProjectName } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/project-name'));
10
+ const { getE2eProjectName } = require('@nx/cypress/src/utils/project-name');
11
11
  const e2eProjectName = getE2eProjectName(options.project, project.root, options.cypressDirectory);
12
12
  await (0, stories_1.angularStoriesGenerator)(tree, {
13
13
  name: options.project,
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAllFilesRecursivelyFromDir = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const devkit_1 = require("@nx/devkit");
5
- const ignore_1 = require("ignore");
6
+ const ignore_1 = tslib_1.__importDefault(require("ignore"));
6
7
  function getAllFilesRecursivelyFromDir(tree, dir) {
7
8
  if (isPathIgnored(tree, dir)) {
8
9
  return [];
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.versions = exports.getInstalledPackageVersionInfo = exports.getInstalledPackageVersion = exports.getInstalledAngularVersionInfo = exports.getInstalledAngularMajorVersion = exports.getInstalledAngularVersion = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const devkit_1 = require("@nx/devkit");
5
6
  const semver_1 = require("semver");
6
7
  const backward_compatible_versions_1 = require("../../utils/backward-compatible-versions");
7
- const latestVersions = require("../../utils/versions");
8
+ const latestVersions = tslib_1.__importStar(require("../../utils/versions"));
8
9
  const versions_1 = require("../../utils/versions");
9
10
  function getInstalledAngularVersion(tree) {
10
11
  const pkgJson = (0, devkit_1.readJson)(tree, 'package.json');
@@ -43,10 +44,10 @@ exports.getInstalledPackageVersionInfo = getInstalledPackageVersionInfo;
43
44
  function versions(tree) {
44
45
  const majorAngularVersion = getInstalledAngularMajorVersion(tree);
45
46
  switch (majorAngularVersion) {
46
- case 15:
47
- return backward_compatible_versions_1.backwardCompatibleVersions.angularV15;
48
47
  case 16:
49
48
  return backward_compatible_versions_1.backwardCompatibleVersions.angularV16;
49
+ case 17:
50
+ return backward_compatible_versions_1.backwardCompatibleVersions.angularV17;
50
51
  default:
51
52
  return latestVersions;
52
53
  }
@@ -19,7 +19,7 @@ exports.DEFAULT_BROWSERS = [
19
19
  async function removeBrowserlistConfig(tree) {
20
20
  let browserslist;
21
21
  try {
22
- browserslist = await Promise.resolve().then(() => require('browserslist'));
22
+ browserslist = await import('browserslist');
23
23
  }
24
24
  catch {
25
25
  devkit_1.logger.warn('Skipping migration because the "browserslist" package could not be loaded.');
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
3
4
  const devkit_1 = require("@nx/devkit");
4
- const ts = require("typescript");
5
+ const ts = tslib_1.__importStar(require("typescript"));
5
6
  const file_change_recorder_1 = require("../../utils/file-change-recorder");
6
7
  async function default_1(tree) {
7
8
  (0, devkit_1.visitNotIgnoredFiles)(tree, '/', (path) => {
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
3
4
  const devkit_1 = require("@nx/devkit");
4
- const ts = require("typescript");
5
+ const ts = tslib_1.__importStar(require("typescript"));
5
6
  const workspace_models_1 = require("@schematics/angular/utility/workspace-models");
6
7
  const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
7
8
  const file_change_recorder_1 = require("../../utils/file-change-recorder");
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
3
4
  const devkit_1 = require("@nx/devkit");
4
- const ts = require("typescript");
5
+ const ts = tslib_1.__importStar(require("typescript"));
5
6
  const file_change_recorder_1 = require("../../utils/file-change-recorder");
6
7
  async function default_1(tree) {
7
8
  (0, devkit_1.visitNotIgnoredFiles)(tree, '/', (path) => {
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export declare const angularCliVersion = "~18.0.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
+ const devkit_1 = require("@nx/devkit");
5
+ exports.angularCliVersion = '~18.0.0';
6
+ async function default_1(tree) {
7
+ let shouldFormat = false;
8
+ (0, devkit_1.updateJson)(tree, 'package.json', (json) => {
9
+ if (json.devDependencies?.['@angular/cli']) {
10
+ json.devDependencies['@angular/cli'] = exports.angularCliVersion;
11
+ shouldFormat = true;
12
+ }
13
+ else if (json.dependencies?.['@angular/cli']) {
14
+ json.dependencies['@angular/cli'] = exports.angularCliVersion;
15
+ shouldFormat = true;
16
+ }
17
+ return json;
18
+ });
19
+ if (shouldFormat) {
20
+ await (0, devkit_1.formatFiles)(tree);
21
+ }
22
+ }
23
+ exports.default = default_1;
@@ -1,8 +1,13 @@
1
1
  import * as latestVersions from './versions';
2
- type SupportedVersions = 'angularV15' | 'angularV16';
3
- export type LatestPackageVersionNames = Exclude<keyof typeof latestVersions, 'nxVersion'>;
4
- export type CompatPackageVersionNames = LatestPackageVersionNames | 'ngUniversalVersion';
2
+ type SupportedVersions = 'angularV16' | 'angularV17';
3
+ type LatestPackageVersionNames = Exclude<keyof typeof latestVersions, 'nxVersion'>;
4
+ type CompatPackageVersionNames = LatestPackageVersionNames | 'ngUniversalVersion';
5
+ export type PackageVersionNames = LatestPackageVersionNames | CompatPackageVersionNames;
6
+ export type VersionMap = {
7
+ angularV16: Record<CompatPackageVersionNames, string>;
8
+ angularV17: Record<Exclude<CompatPackageVersionNames, 'ngUniversalVersion'>, string>;
9
+ };
5
10
  export type PackageLatestVersions = Record<LatestPackageVersionNames, string>;
6
- export type PackageCompatVersions = Record<CompatPackageVersionNames, string>;
7
- export declare const backwardCompatibleVersions: Record<SupportedVersions, PackageCompatVersions>;
11
+ export type PackageCompatVersions = VersionMap[SupportedVersions];
12
+ export declare const backwardCompatibleVersions: VersionMap;
8
13
  export {};