@nx/angular 17.1.0-beta.2 → 17.1.0-beta.4

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 (191) hide show
  1. package/fesm2022/nx-angular.mjs +1 -1
  2. package/migrations.json +135 -0
  3. package/ng-package.json +0 -1
  4. package/package.json +14 -19
  5. package/src/builders/module-federation-dev-server/module-federation-dev-server.impl.d.ts +1 -1
  6. package/src/builders/module-federation-dev-server/module-federation-dev-server.impl.js +112 -60
  7. package/src/builders/module-federation-dev-server/schema.d.ts +23 -7
  8. package/src/builders/module-federation-dev-server/schema.json +13 -3
  9. package/src/builders/module-federation-dev-ssr/module-federation-dev-ssr.impl.d.ts +1 -1
  10. package/src/builders/module-federation-dev-ssr/module-federation-dev-ssr.impl.js +13 -8
  11. package/src/builders/webpack-browser/schema.json +7 -7
  12. package/src/builders/webpack-browser/webpack-browser.impl.js +0 -2
  13. package/src/builders/webpack-dev-server/lib/normalize-options.d.ts +2 -2
  14. package/src/builders/webpack-dev-server/lib/normalize-options.js +11 -5
  15. package/src/builders/webpack-dev-server/schema.d.ts +22 -7
  16. package/src/builders/webpack-dev-server/schema.json +9 -3
  17. package/src/builders/webpack-dev-server/webpack-dev-server.impl.js +24 -13
  18. package/src/builders/webpack-server/schema.d.ts +0 -1
  19. package/src/builders/webpack-server/schema.json +1 -13
  20. package/src/builders/webpack-server/validate-options.js +0 -7
  21. package/src/builders/webpack-server/webpack-server.impl.js +0 -8
  22. package/src/executors/browser-esbuild/browser-esbuild.impl.js +0 -2
  23. package/src/executors/browser-esbuild/schema.json +5 -4
  24. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/write-package.transform.js +20 -12
  25. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ngc/compile-source-files.js +10 -1
  26. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/styles/stylesheet-processor.js +0 -13
  27. package/src/executors/package/ng-packagr-adjustments/ngc/compile-source-files.js +10 -1
  28. package/src/executors/package/ng-packagr-adjustments/styles/stylesheet-processor.js +0 -13
  29. package/src/executors/utilities/ng-compiler-cli.d.ts +15 -0
  30. package/src/executors/utilities/ng-compiler-cli.js +28 -0
  31. package/src/executors/utilities/typescript.js +1 -1
  32. package/src/generators/application/application.js +7 -17
  33. package/src/generators/application/files/base/tsconfig.app.json__tpl__ +1 -1
  34. package/src/generators/application/files/base/tsconfig.json__tpl__ +3 -2
  35. package/src/generators/application/files/ng-module/src/app/app.module.ts__tpl__ +1 -1
  36. package/src/generators/application/files/ng-module/src/app/nx-welcome.component.ts__tpl__ +2 -2
  37. package/src/generators/application/files/ng-module/src/main.ts__tpl__ +2 -8
  38. package/src/generators/application/files/standalone-components/src/app/app.config.ts__tpl__ +2 -2
  39. package/src/generators/application/files/standalone-components/src/app/nx-welcome.component.ts__tpl__ +2 -2
  40. package/src/generators/application/lib/add-e2e.js +7 -1
  41. package/src/generators/application/lib/create-files.js +10 -5
  42. package/src/generators/application/lib/create-project.js +46 -38
  43. package/src/generators/application/lib/normalize-options.d.ts +1 -1
  44. package/src/generators/application/lib/normalize-options.js +14 -3
  45. package/src/generators/application/lib/normalized-schema.d.ts +2 -0
  46. package/src/generators/application/schema.d.ts +1 -0
  47. package/src/generators/application/schema.json +13 -6
  48. package/src/generators/component/component.js +0 -1
  49. package/src/generators/component/lib/index.d.ts +0 -1
  50. package/src/generators/component/lib/index.js +0 -1
  51. package/src/generators/component/lib/normalize-options.js +1 -0
  52. package/src/generators/component/schema.json +2 -2
  53. package/src/generators/directive/directive.js +0 -1
  54. package/src/generators/directive/lib/index.d.ts +0 -1
  55. package/src/generators/directive/lib/index.js +0 -1
  56. package/src/generators/directive/lib/normalize-options.js +1 -0
  57. package/src/generators/directive/schema.json +2 -2
  58. package/src/generators/federate-module/federate-module.js +1 -0
  59. package/src/generators/federate-module/lib/add-remote.d.ts +1 -1
  60. package/src/generators/federate-module/lib/add-remote.js +2 -11
  61. package/src/generators/federate-module/schema.json +2 -2
  62. package/src/generators/host/files/common/v17+/src/main.server.ts__tmpl__ +67 -0
  63. package/src/generators/host/host.js +5 -9
  64. package/src/generators/host/lib/index.d.ts +1 -1
  65. package/src/generators/host/lib/index.js +1 -1
  66. package/src/generators/host/lib/update-ssr-setup.d.ts +3 -0
  67. package/src/generators/host/lib/{add-ssr.js → update-ssr-setup.js} +8 -14
  68. package/src/generators/host/schema.json +2 -2
  69. package/src/generators/library/lib/normalize-options.js +1 -0
  70. package/src/generators/library/library.js +0 -5
  71. package/src/generators/library/schema.json +12 -12
  72. package/src/generators/ng-add/migrators/projects/app.migrator.js +50 -7
  73. package/src/generators/ngrx/lib/generate-files.js +1 -10
  74. package/src/generators/ngrx/lib/validate-options.js +0 -23
  75. package/src/generators/ngrx/schema.json +2 -2
  76. package/src/generators/ngrx-feature-store/lib/generate-files.js +1 -12
  77. package/src/generators/ngrx-feature-store/lib/validate-options.js +0 -22
  78. package/src/generators/ngrx-feature-store/schema.json +2 -2
  79. package/src/generators/ngrx-root-store/lib/normalize-options.js +1 -1
  80. package/src/generators/ngrx-root-store/lib/validate-options.js +0 -15
  81. package/src/generators/ngrx-root-store/schema.json +1 -1
  82. package/src/generators/pipe/lib/index.d.ts +0 -1
  83. package/src/generators/pipe/lib/index.js +0 -1
  84. package/src/generators/pipe/lib/normalize-options.js +1 -0
  85. package/src/generators/pipe/pipe.js +0 -1
  86. package/src/generators/pipe/schema.json +2 -2
  87. package/src/generators/remote/files/common/v17+/src/main.server.ts__tmpl__ +74 -0
  88. package/src/generators/remote/lib/index.d.ts +1 -1
  89. package/src/generators/remote/lib/index.js +1 -1
  90. package/src/generators/remote/lib/{add-ssr.d.ts → update-ssr-setup.d.ts} +1 -1
  91. package/src/generators/remote/lib/{add-ssr.js → update-ssr-setup.js} +9 -13
  92. package/src/generators/remote/remote.js +4 -9
  93. package/src/generators/remote/schema.json +2 -2
  94. package/src/generators/scam-to-standalone/scam-to-standalone.js +0 -7
  95. package/src/generators/scam-to-standalone/schema.json +1 -1
  96. package/src/generators/setup-mf/lib/add-remote-entry.js +2 -11
  97. package/src/generators/setup-mf/lib/fix-bootstrap.js +3 -12
  98. package/src/generators/setup-mf/lib/index.d.ts +1 -1
  99. package/src/generators/setup-mf/lib/index.js +1 -1
  100. package/src/generators/setup-mf/lib/normalize-options.js +1 -0
  101. package/src/generators/{component/lib/validate-options.d.ts → setup-mf/lib/update-tsconfig.d.ts} +1 -1
  102. package/src/generators/setup-mf/lib/update-tsconfig.js +19 -0
  103. package/src/generators/setup-mf/schema.json +2 -2
  104. package/src/generators/setup-mf/setup-mf.js +1 -7
  105. package/src/generators/setup-ssr/files/server/application-builder/__serverFileName__ +54 -0
  106. package/src/generators/setup-ssr/files/{ngmodule/base → server/server-builder/pre-v17}/__serverFileName__ +3 -4
  107. package/src/generators/setup-ssr/files/{standalone → server/server-builder/v17+}/__serverFileName__ +25 -16
  108. package/src/generators/setup-ssr/lib/add-dependencies.d.ts +2 -0
  109. package/src/generators/setup-ssr/lib/add-dependencies.js +32 -0
  110. package/src/generators/setup-ssr/lib/generate-files.d.ts +1 -1
  111. package/src/generators/setup-ssr/lib/generate-files.js +10 -13
  112. package/src/generators/setup-ssr/lib/generate-server-ts-config.d.ts +4 -0
  113. package/src/generators/setup-ssr/lib/generate-server-ts-config.js +26 -0
  114. package/src/generators/setup-ssr/lib/index.d.ts +3 -0
  115. package/src/generators/setup-ssr/lib/index.js +3 -0
  116. package/src/generators/setup-ssr/lib/normalize-options.js +7 -1
  117. package/src/generators/setup-ssr/lib/set-router-initial-navigation.d.ts +3 -0
  118. package/src/generators/setup-ssr/lib/set-router-initial-navigation.js +93 -0
  119. package/src/generators/setup-ssr/lib/update-project-config.d.ts +2 -1
  120. package/src/generators/setup-ssr/lib/update-project-config.js +24 -6
  121. package/src/generators/setup-ssr/lib/validate-options.js +15 -2
  122. package/src/generators/setup-ssr/schema.json +3 -3
  123. package/src/generators/setup-ssr/setup-ssr.js +16 -12
  124. package/src/generators/utils/create-ts-config.d.ts +1 -0
  125. package/src/generators/utils/create-ts-config.js +2 -3
  126. package/src/generators/utils/testing.js +12 -0
  127. package/src/generators/utils/validations.d.ts +0 -1
  128. package/src/generators/utils/validations.js +1 -14
  129. package/src/generators/utils/version-utils.d.ts +2 -2
  130. package/src/generators/utils/version-utils.js +3 -3
  131. package/src/migrations/update-17-1-0/browser-target-to-build-target.d.ts +3 -0
  132. package/src/migrations/update-17-1-0/browser-target-to-build-target.js +50 -0
  133. package/src/migrations/update-17-1-0/replace-nguniversal-builders.d.ts +2 -0
  134. package/src/migrations/update-17-1-0/replace-nguniversal-builders.js +75 -0
  135. package/src/migrations/update-17-1-0/replace-nguniversal-engines.d.ts +2 -0
  136. package/src/migrations/update-17-1-0/replace-nguniversal-engines.js +185 -0
  137. package/src/migrations/update-17-1-0/update-angular-cli.d.ts +3 -0
  138. package/src/migrations/update-17-1-0/update-angular-cli.js +23 -0
  139. package/src/migrations/update-17-1-0/update-zone-js-deep-import.d.ts +2 -0
  140. package/src/migrations/update-17-1-0/update-zone-js-deep-import.js +37 -0
  141. package/src/utils/backward-compatible-versions.d.ts +6 -4
  142. package/src/utils/backward-compatible-versions.js +18 -18
  143. package/src/utils/nx-devkit/ast-utils.js +4 -2
  144. package/src/utils/version-utils.d.ts +3 -3
  145. package/src/utils/versions.d.ts +6 -7
  146. package/src/utils/versions.js +7 -8
  147. package/src/builders/webpack-browser/validate-options.d.ts +0 -2
  148. package/src/builders/webpack-browser/validate-options.js +0 -40
  149. package/src/executors/browser-esbuild/lib/validate-options.d.ts +0 -2
  150. package/src/executors/browser-esbuild/lib/validate-options.js +0 -40
  151. package/src/generators/application/files/tsconfig.editor.json__tpl__ +0 -5
  152. package/src/generators/application/files/v14/.browserlistrc__tpl__ +0 -16
  153. package/src/generators/application/files/v14/src/environments/environment.prod.ts__tpl__ +0 -3
  154. package/src/generators/application/files/v14/src/environments/environment.ts__tpl__ +0 -16
  155. package/src/generators/application/files/v14/src/polyfills.ts__tpl__ +0 -53
  156. package/src/generators/component/lib/validate-options.js +0 -8
  157. package/src/generators/directive/lib/validate-options.d.ts +0 -3
  158. package/src/generators/directive/lib/validate-options.js +0 -8
  159. package/src/generators/host/lib/add-ssr.d.ts +0 -3
  160. package/src/generators/ngrx/files/no-inject/__directory__/__fileName__.effects.ts__tmpl__ +0 -22
  161. package/src/generators/ngrx/files/no-inject/__directory__/__fileName__.facade.ts__tmpl__ +0 -27
  162. package/src/generators/ngrx-feature-store/files/no-inject/__directory__/__fileName__.effects.ts__tmpl__ +0 -22
  163. package/src/generators/ngrx-feature-store/files/no-inject/__directory__/__fileName__.facade.ts__tmpl__ +0 -27
  164. package/src/generators/pipe/lib/validate-options.d.ts +0 -3
  165. package/src/generators/pipe/lib/validate-options.js +0 -8
  166. package/src/generators/setup-mf/lib/set-tsconfig-target.d.ts +0 -3
  167. package/src/generators/setup-mf/lib/set-tsconfig-target.js +0 -16
  168. package/src/generators/setup-ssr/files/ngmodule/v14/src/__main__ +0 -11
  169. /package/src/generators/host/files/common/{src → pre-v17/src}/main.server.ts__tmpl__ +0 -0
  170. /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.actions.ts__tmpl__ +0 -0
  171. /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.effects.spec.ts__tmpl__ +0 -0
  172. /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.effects.ts__tmpl__ +0 -0
  173. /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.facade.spec.ts__tmpl__ +0 -0
  174. /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.facade.ts__tmpl__ +0 -0
  175. /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.models.ts__tmpl__ +0 -0
  176. /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.reducer.spec.ts__tmpl__ +0 -0
  177. /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.reducer.ts__tmpl__ +0 -0
  178. /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.selectors.spec.ts__tmpl__ +0 -0
  179. /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.selectors.ts__tmpl__ +0 -0
  180. /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.actions.ts__tmpl__ +0 -0
  181. /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.effects.spec.ts__tmpl__ +0 -0
  182. /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.effects.ts__tmpl__ +0 -0
  183. /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.facade.spec.ts__tmpl__ +0 -0
  184. /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.facade.ts__tmpl__ +0 -0
  185. /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.models.ts__tmpl__ +0 -0
  186. /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.reducer.spec.ts__tmpl__ +0 -0
  187. /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.reducer.ts__tmpl__ +0 -0
  188. /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.selectors.spec.ts__tmpl__ +0 -0
  189. /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.selectors.ts__tmpl__ +0 -0
  190. /package/src/generators/remote/files/common/{src → pre-v17/src}/main.server.ts__tmpl__ +0 -0
  191. /package/src/generators/setup-ssr/files/{base → root}/tsconfig.server.json__tpl__ +0 -0
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./add-ssr"), exports);
4
+ tslib_1.__exportStar(require("./update-ssr-setup"), exports);
@@ -0,0 +1,3 @@
1
+ import type { Tree } from '@nx/devkit';
2
+ import type { Schema } from '../schema';
3
+ export declare function updateSsrSetup(tree: Tree, options: Schema, appName: string, typescriptConfiguration: boolean): Promise<import("@nx/devkit").GeneratorCallback>;
@@ -1,22 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addSsr = void 0;
3
+ exports.updateSsrSetup = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const setup_ssr_1 = require("../../setup-ssr/setup-ssr");
6
- const versions_1 = require("../../../utils/versions");
7
5
  const path_1 = require("path");
8
- async function addSsr(tree, options, appName, typescriptConfiguration) {
6
+ const versions_1 = require("../../../utils/versions");
7
+ const version_utils_1 = require("../../utils/version-utils");
8
+ async function updateSsrSetup(tree, options, appName, typescriptConfiguration) {
9
9
  let project = (0, devkit_1.readProjectConfiguration)(tree, appName);
10
- await (0, setup_ssr_1.default)(tree, {
11
- project: appName,
12
- standalone: options.standalone,
13
- });
14
10
  tree.rename((0, devkit_1.joinPathFragments)(project.sourceRoot, 'main.server.ts'), (0, devkit_1.joinPathFragments)(project.sourceRoot, 'bootstrap.server.ts'));
15
11
  tree.write((0, devkit_1.joinPathFragments)(project.root, 'server.ts'), "import('./src/main.server');");
16
- const browserBundleOutput = (0, devkit_1.joinPathFragments)(project.targets.build.options.outputPath, 'browser');
17
- (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, '../files/common'), project.root, {
12
+ const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
13
+ (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, '../files/common', angularMajorVersion >= 17 ? 'v17+' : 'pre-v17'), project.root, {
18
14
  appName,
19
- browserBundleOutput,
15
+ browserBundleOutput: project.targets.build.options.outputPath,
20
16
  standalone: options.standalone,
21
17
  tmpl: '',
22
18
  });
@@ -35,12 +31,10 @@ async function addSsr(tree, options, appName, typescriptConfiguration) {
35
31
  (0, devkit_1.updateProjectConfiguration)(tree, appName, project);
36
32
  const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {
37
33
  cors: versions_1.corsVersion,
38
- express: versions_1.expressVersion,
39
34
  '@module-federation/node': versions_1.moduleFederationNodeVersion,
40
35
  }, {
41
36
  '@types/cors': versions_1.typesCorsVersion,
42
- '@types/express': versions_1.typesExpressVersion,
43
37
  });
44
38
  return installTask;
45
39
  }
46
- exports.addSsr = addSsr;
40
+ exports.updateSsrSetup = updateSsrSetup;
@@ -165,8 +165,8 @@
165
165
  },
166
166
  "standalone": {
167
167
  "type": "boolean",
168
- "description": "Whether to generate a host application that uses standalone components. _Note: This is only supported in Angular versions >= 14.1.0_",
169
- "default": false
168
+ "description": "Whether to generate a host application that uses standalone components.",
169
+ "default": true
170
170
  },
171
171
  "ssr": {
172
172
  "description": "Whether to configure SSR for the host application",
@@ -8,6 +8,7 @@ const eslint_1 = require("@nx/eslint");
8
8
  const test_runners_1 = require("../../../utils/test-runners");
9
9
  const project_1 = require("../../utils/project");
10
10
  async function normalizeOptions(host, schema) {
11
+ schema.standalone = schema.standalone ?? true;
11
12
  // Create a schema with populated default values
12
13
  const options = {
13
14
  buildable: false,
@@ -5,7 +5,6 @@ const devkit_1 = require("@nx/devkit");
5
5
  const jest_1 = require("@nx/jest");
6
6
  const eslint_1 = require("@nx/eslint");
7
7
  const js_1 = require("@nx/js");
8
- const semver_1 = require("semver");
9
8
  const init_1 = require("../../generators/init/init");
10
9
  const test_runners_1 = require("../../utils/test-runners");
11
10
  const add_linting_1 = require("../add-linting/add-linting");
@@ -40,10 +39,6 @@ async function libraryGeneratorInternal(tree, schema) {
40
39
  if (schema.addTailwind && !schema.buildable && !schema.publishable) {
41
40
  throw new Error(`To use "--addTailwind" option, you have to set either "--buildable" or "--publishable".`);
42
41
  }
43
- const userInstalledAngularVersion = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
44
- if ((0, semver_1.lt)(userInstalledAngularVersion.version, '14.1.0') && schema.standalone) {
45
- throw new Error(`The "--standalone" option is not supported in Angular versions < 14.1.0.`);
46
- }
47
42
  const options = await (0, normalize_options_1.normalizeOptions)(tree, schema);
48
43
  const { libraryOptions } = options;
49
44
  const pkgVersions = (0, version_utils_1.versions)(tree);
@@ -141,65 +141,65 @@
141
141
  },
142
142
  "standalone": {
143
143
  "type": "boolean",
144
- "description": "Generate a library that uses a standalone component instead of a module as the entry point. _Note: This is only supported in Angular versions >= 14.1.0_",
145
- "default": false
144
+ "description": "Generate a library that uses a standalone component instead of a module as the entry point.",
145
+ "default": true
146
146
  },
147
147
  "displayBlock": {
148
- "description": "Specifies if the component generated style will contain `:host { display: block; }`. Disclaimer: This option is only valid when `--standalone` is set to `true`. _Note: This is only supported in Angular versions >= 14.1.0_",
148
+ "description": "Specifies if the component generated style will contain `:host { display: block; }`. Disclaimer: This option is only valid when `--standalone` is set to `true`.",
149
149
  "type": "boolean",
150
150
  "default": false,
151
151
  "alias": "b"
152
152
  },
153
153
  "inlineStyle": {
154
- "description": "Include styles inline in the component.ts file. Only CSS styles can be included inline. By default, an external styles file is created and referenced in the component.ts file. Disclaimer: This option is only valid when `--standalone` is set to `true`. _Note: This is only supported in Angular versions >= 14.1.0_",
154
+ "description": "Include styles inline in the component.ts file. Only CSS styles can be included inline. By default, an external styles file is created and referenced in the component.ts file. Disclaimer: This option is only valid when `--standalone` is set to `true`.",
155
155
  "type": "boolean",
156
156
  "default": false,
157
157
  "alias": "s"
158
158
  },
159
159
  "inlineTemplate": {
160
- "description": "Include template inline in the component.ts file. By default, an external template file is created and referenced in the component.ts file. Disclaimer: This option is only valid when `--standalone` is set to `true`. _Note: This is only supported in Angular versions >= 14.1.0_",
160
+ "description": "Include template inline in the component.ts file. By default, an external template file is created and referenced in the component.ts file. Disclaimer: This option is only valid when `--standalone` is set to `true`.",
161
161
  "type": "boolean",
162
162
  "default": false,
163
163
  "alias": "t"
164
164
  },
165
165
  "viewEncapsulation": {
166
- "description": "The view encapsulation strategy to use in the new component. Disclaimer: This option is only valid when `--standalone` is set to `true`. _Note: This is only supported in Angular versions >= 14.1.0_",
166
+ "description": "The view encapsulation strategy to use in the new component. Disclaimer: This option is only valid when `--standalone` is set to `true`.",
167
167
  "enum": ["Emulated", "None", "ShadowDom"],
168
168
  "type": "string",
169
169
  "alias": "v"
170
170
  },
171
171
  "changeDetection": {
172
- "description": "The change detection strategy to use in the new component. Disclaimer: This option is only valid when `--standalone` is set to `true`. _Note: This is only supported in Angular versions >= 14.1.0_",
172
+ "description": "The change detection strategy to use in the new component. Disclaimer: This option is only valid when `--standalone` is set to `true`.",
173
173
  "enum": ["Default", "OnPush"],
174
174
  "type": "string",
175
175
  "default": "Default",
176
176
  "alias": "c"
177
177
  },
178
178
  "style": {
179
- "description": "The file extension or preprocessor to use for style files, or `none` to skip generating the style file. Disclaimer: This option is only valid when `--standalone` is set to `true`. _Note: This is only supported in Angular versions >= 14.1.0_",
179
+ "description": "The file extension or preprocessor to use for style files, or `none` to skip generating the style file. Disclaimer: This option is only valid when `--standalone` is set to `true`.",
180
180
  "type": "string",
181
181
  "default": "css",
182
182
  "enum": ["css", "scss", "sass", "less", "none"]
183
183
  },
184
184
  "skipTests": {
185
185
  "type": "boolean",
186
- "description": "Do not create `spec.ts` test files for the new component. Disclaimer: This option is only valid when `--standalone` is set to `true`. _Note: This is only supported in Angular versions >= 14.1.0_",
186
+ "description": "Do not create `spec.ts` test files for the new component. Disclaimer: This option is only valid when `--standalone` is set to `true`.",
187
187
  "default": false
188
188
  },
189
189
  "selector": {
190
190
  "type": "string",
191
191
  "format": "html-selector",
192
- "description": "The HTML selector to use for this component. Disclaimer: This option is only valid when `--standalone` is set to `true`. _Note: This is only supported in Angular versions >= 14.1.0_"
192
+ "description": "The HTML selector to use for this component. Disclaimer: This option is only valid when `--standalone` is set to `true`."
193
193
  },
194
194
  "skipSelector": {
195
195
  "type": "boolean",
196
196
  "default": false,
197
- "description": "Specifies if the component should have a selector or not. Disclaimer: This option is only valid when `--standalone` is set to `true`. _Note: This is only supported in Angular versions >= 14.1.0_"
197
+ "description": "Specifies if the component should have a selector or not. Disclaimer: This option is only valid when `--standalone` is set to `true`."
198
198
  },
199
199
  "flat": {
200
200
  "type": "boolean",
201
201
  "default": false,
202
- "description": "Ensure the generated standalone component is not placed in a subdirectory. Disclaimer: This option is only valid when `--standalone` is set to `true`. _Note: This is only supported in Angular versions >= 14.1.0_"
202
+ "description": "Ensure the generated standalone component is not placed in a subdirectory. Disclaimer: This option is only valid when `--standalone` is set to `true`."
203
203
  }
204
204
  },
205
205
  "additionalProperties": false,
@@ -9,7 +9,13 @@ const builders_1 = require("../builders");
9
9
  const e2e_migrator_1 = require("./e2e.migrator");
10
10
  const project_migrator_1 = require("./project.migrator");
11
11
  const supportedTargets = {
12
- build: { builders: ['@angular-devkit/build-angular:browser'] },
12
+ build: {
13
+ builders: [
14
+ '@angular-devkit/build-angular:application',
15
+ '@angular-devkit/build-angular:browser',
16
+ '@angular-devkit/build-angular:browser-esbuild',
17
+ ],
18
+ },
13
19
  e2e: {
14
20
  acceptMultipleDefinitions: true,
15
21
  builders: [
@@ -18,10 +24,20 @@ const supportedTargets = {
18
24
  ],
19
25
  },
20
26
  i18n: { builders: ['@angular-devkit/build-angular:extract-i18n'] },
21
- prerender: { builders: ['@nguniversal/builders:prerender'] },
27
+ prerender: {
28
+ builders: [
29
+ '@nguniversal/builders:prerender',
30
+ '@angular-devkit/build-angular:prerender',
31
+ ],
32
+ },
22
33
  serve: { builders: ['@angular-devkit/build-angular:dev-server'] },
23
34
  server: { builders: ['@angular-devkit/build-angular:server'] },
24
- serveSsr: { builders: ['@nguniversal/builders:ssr-dev-server'] },
35
+ serveSsr: {
36
+ builders: [
37
+ '@nguniversal/builders:ssr-dev-server',
38
+ '@angular-devkit/build-angular:ssr-dev-server',
39
+ ],
40
+ },
25
41
  };
26
42
  // TODO(leo): this will replace `supportedTargets` once the full refactor is done.
27
43
  const supportedBuilderMigrators = [
@@ -125,10 +141,22 @@ class AppMigrator extends project_migrator_1.ProjectMigrator {
125
141
  buildOptions.outputPath =
126
142
  buildOptions.outputPath &&
127
143
  (0, devkit_1.joinPathFragments)('dist', this.project.newRoot, this.targetNames.server ? 'browser' : '');
128
- buildOptions.index =
129
- buildOptions.index && this.convertAsset(buildOptions.index);
144
+ if (buildOptions.index) {
145
+ if (typeof buildOptions.index === 'string') {
146
+ buildOptions.index = this.convertAsset(buildOptions.index);
147
+ }
148
+ else {
149
+ buildOptions.index.input =
150
+ buildOptions.index.input &&
151
+ this.convertAsset(buildOptions.index.input);
152
+ }
153
+ }
130
154
  buildOptions.main =
131
155
  buildOptions.main && this.convertAsset(buildOptions.main);
156
+ buildOptions.browser =
157
+ buildOptions.browser && this.convertAsset(buildOptions.browser);
158
+ buildOptions.server =
159
+ buildOptions.server && this.convertAsset(buildOptions.server);
132
160
  buildOptions.polyfills =
133
161
  buildOptions.polyfills &&
134
162
  (Array.isArray(buildOptions.polyfills)
@@ -152,6 +180,20 @@ class AppMigrator extends project_migrator_1.ProjectMigrator {
152
180
  replace: this.convertAsset(replacement.replace),
153
181
  with: this.convertAsset(replacement.with),
154
182
  }));
183
+ buildOptions.serviceWorker =
184
+ buildOptions.serviceWorker &&
185
+ typeof buildOptions.serviceWorker === 'string' &&
186
+ this.convertAsset(buildOptions.serviceWorker);
187
+ buildOptions.ngswConfigPath =
188
+ buildOptions.ngswConfigPath &&
189
+ this.convertAsset(buildOptions.ngswConfigPath);
190
+ if (buildOptions.prerender?.routesFile) {
191
+ buildOptions.prerender.routesFile = this.convertAsset(buildOptions.prerender.routesFile);
192
+ }
193
+ buildOptions.ssr =
194
+ buildOptions.ssr &&
195
+ typeof buildOptions.ssr === 'string' &&
196
+ this.convertAsset(buildOptions.ssr);
155
197
  }
156
198
  convertServerOptions(serverOptions) {
157
199
  serverOptions.outputPath =
@@ -243,11 +285,12 @@ class AppMigrator extends project_migrator_1.ProjectMigrator {
243
285
  this.shouldSkipTargetTypeMigration('serveSsr')) {
244
286
  return;
245
287
  }
246
- const serveSsrTarget = this.projectConfig.targets[this.targetNames.serveSsr];
288
+ const ssrTarget = this.targetNames.serveSsr ?? this.targetNames['serve-ssr'];
289
+ const serveSsrTarget = this.projectConfig.targets[ssrTarget];
247
290
  if (!serveSsrTarget.options &&
248
291
  (!serveSsrTarget.configurations ||
249
292
  !Object.keys(serveSsrTarget.configurations).length)) {
250
- this.logger.warn(`The target "${this.targetNames.serveSsr}" is not specifying any options or configurations. Skipping updating the target configuration.`);
293
+ this.logger.warn(`The target "${ssrTarget}" is not specifying any options or configurations. Skipping updating the target configuration.`);
251
294
  return;
252
295
  }
253
296
  ['sslKey', 'sslCert', 'proxyConfig'].forEach((option) => {
@@ -3,27 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateNgrxFilesFromTemplates = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const semver_1 = require("semver");
6
- const version_utils_1 = require("../../utils/version-utils");
7
6
  /**
8
7
  * Generate 'feature' scaffolding: actions, reducer, effects, interfaces, selectors, facade
9
8
  */
10
9
  function generateNgrxFilesFromTemplates(tree, options) {
11
10
  const name = options.name;
12
11
  const projectNames = (0, devkit_1.names)(name);
13
- (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '..', 'files', 'base'), options.parentDirectory, {
12
+ (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '..', 'files'), options.parentDirectory, {
14
13
  ...options,
15
14
  ...projectNames,
16
15
  importFromOperators: (0, semver_1.lt)(options.rxjsVersion, '7.2.0'),
17
16
  tmpl: '',
18
17
  });
19
- const angularVersion = (0, version_utils_1.getInstalledAngularVersion)(tree);
20
- if ((0, semver_1.lt)(angularVersion, '14.1.0')) {
21
- (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '..', 'files', 'no-inject'), options.parentDirectory, {
22
- ...options,
23
- ...projectNames,
24
- tmpl: '',
25
- });
26
- }
27
18
  if (!options.facade) {
28
19
  tree.delete((0, devkit_1.joinPathFragments)(options.parentDirectory, options.directory, `${projectNames.fileName}.facade.ts`));
29
20
  tree.delete((0, devkit_1.joinPathFragments)(options.parentDirectory, options.directory, `${projectNames.fileName}.facade.spec.ts`));
@@ -1,9 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateOptions = void 0;
4
- const semver_1 = require("semver");
5
- const version_utils_1 = require("../../utils/version-utils");
6
- const version_utils_2 = require("../../../utils/version-utils");
7
4
  function validateOptions(tree, options) {
8
5
  if (!options.module && !options.parent) {
9
6
  throw new Error('Please provide a value for "--parent"!');
@@ -14,25 +11,5 @@ function validateOptions(tree, options) {
14
11
  if (options.parent && !tree.exists(options.parent)) {
15
12
  throw new Error(`Parent does not exist: ${options.parent}.`);
16
13
  }
17
- const angularVersionInfo = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
18
- const intendedNgRxVersionForAngularMajor = (0, version_utils_2.getPkgVersionForAngularMajorVersion)('ngrxVersion', angularVersionInfo.major);
19
- const ngrxMajorVersion = (0, version_utils_1.getInstalledPackageVersionInfo)(tree, '@ngrx/store')?.major ??
20
- (0, semver_1.major)((0, semver_1.coerce)(intendedNgRxVersionForAngularMajor));
21
- if ((0, semver_1.lt)(angularVersionInfo.version, '14.1.0') || ngrxMajorVersion < 15) {
22
- const parentPath = options.parent ?? options.module;
23
- const parentContent = tree.read(parentPath, 'utf-8');
24
- const { tsquery } = require('@phenomnomnominal/tsquery');
25
- const ast = tsquery.ast(parentContent);
26
- const NG_MODULE_DECORATOR_SELECTOR = 'ClassDeclaration > Decorator > CallExpression:has(Identifier[name=NgModule])';
27
- const nodes = tsquery(ast, NG_MODULE_DECORATOR_SELECTOR, {
28
- visitAllChildren: true,
29
- });
30
- if (nodes.length === 0) {
31
- throw new Error(`The provided parent path "${parentPath}" does not contain an "NgModule". ` +
32
- 'Please make sure to provide a path to an "NgModule" where the state will be registered. ' +
33
- 'If you are trying to use a "Routes" definition file (for Standalone API usage), ' +
34
- 'please note this is not supported in Angular versions lower than 14.1.0.');
35
- }
36
- }
37
14
  }
38
15
  exports.validateOptions = validateOptions;
@@ -42,13 +42,13 @@
42
42
  },
43
43
  "parent": {
44
44
  "type": "string",
45
- "description": "The path to the file where the state will be registered. For NgModule usage, this will be your `app.module.ts` for your root state, or your Feature Module for feature state. For Standalone API usage, this will be your `app.config.ts` file for your root state, or the Routes definition file for your feature state. The host directory will create/use the new state directory. _Note: The Standalone API usage is only supported in Angular versions >= 14.1.0_.",
45
+ "description": "The path to the file where the state will be registered. For NgModule usage, this will be your `app.module.ts` for your root state, or your Feature Module for feature state. For Standalone API usage, this will be your `app.config.ts` file for your root state, or the Routes definition file for your feature state. The host directory will create/use the new state directory.",
46
46
  "x-prompt": "What is the path to the module or Routes definition where this NgRx state should be registered?",
47
47
  "x-priority": "important"
48
48
  },
49
49
  "route": {
50
50
  "type": "string",
51
- "description": "The route that the Standalone NgRx Providers should be added to. _Note: This is only supported in Angular versions >= 14.1.0_.",
51
+ "description": "The route that the Standalone NgRx Providers should be added to.",
52
52
  "default": "''"
53
53
  },
54
54
  "directory": {
@@ -3,13 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateFilesFromTemplates = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const semver_1 = require("semver");
6
- const version_utils_1 = require("../../utils/version-utils");
7
6
  function generateFilesFromTemplates(tree, options) {
8
7
  const projectNames = (0, devkit_1.names)(options.name);
9
8
  const fileName = options.subdirectory
10
9
  ? (0, devkit_1.joinPathFragments)(options.subdirectory, projectNames.fileName)
11
10
  : projectNames.fileName;
12
- (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '..', 'files', 'base'), options.parentDirectory, {
11
+ (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '..', 'files'), options.parentDirectory, {
13
12
  ...options,
14
13
  ...projectNames,
15
14
  fileName,
@@ -17,16 +16,6 @@ function generateFilesFromTemplates(tree, options) {
17
16
  importFromOperators: (0, semver_1.lt)(options.rxjsVersion, '7.2.0'),
18
17
  tmpl: '',
19
18
  });
20
- const angularVersion = (0, version_utils_1.getInstalledAngularVersion)(tree);
21
- if ((0, semver_1.lt)(angularVersion, '14.1.0')) {
22
- (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '..', 'files', 'no-inject'), options.parentDirectory, {
23
- ...options,
24
- ...projectNames,
25
- fileName,
26
- relativeFileName: projectNames.fileName,
27
- tmpl: '',
28
- });
29
- }
30
19
  if (!options.facade) {
31
20
  tree.delete((0, devkit_1.joinPathFragments)(options.parentDirectory, options.directory, `${options.subdirectory ? `${options.subdirectory}/` : ''}${projectNames.fileName}.facade.ts`));
32
21
  tree.delete((0, devkit_1.joinPathFragments)(options.parentDirectory, options.directory, `${options.subdirectory ? `${options.subdirectory}/` : ''}${projectNames.fileName}.facade.spec.ts`));
@@ -1,9 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateOptions = void 0;
4
- const version_utils_1 = require("../..//utils/version-utils");
5
- const version_utils_2 = require("../../../utils/version-utils");
6
- const semver_1 = require("semver");
7
4
  function validateOptions(tree, options) {
8
5
  if (!options.parent) {
9
6
  throw new Error('Please provide a value for "--parent"!');
@@ -11,24 +8,5 @@ function validateOptions(tree, options) {
11
8
  if (options.parent && !tree.exists(options.parent)) {
12
9
  throw new Error(`Parent does not exist: ${options.parent}.`);
13
10
  }
14
- const angularVersionInfo = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
15
- const intendedNgRxVersionForAngularMajor = (0, version_utils_2.getPkgVersionForAngularMajorVersion)('ngrxVersion', angularVersionInfo.major);
16
- const ngrxMajorVersion = (0, version_utils_1.getInstalledPackageVersionInfo)(tree, '@ngrx/store')?.major ??
17
- (0, semver_1.major)((0, semver_1.coerce)(intendedNgRxVersionForAngularMajor));
18
- if ((0, semver_1.lt)(angularVersionInfo.version, '14.1.0') || ngrxMajorVersion < 15) {
19
- const parentContent = tree.read(options.parent, 'utf-8');
20
- const { tsquery } = require('@phenomnomnominal/tsquery');
21
- const ast = tsquery.ast(parentContent);
22
- const NG_MODULE_DECORATOR_SELECTOR = 'ClassDeclaration > Decorator > CallExpression:has(Identifier[name=NgModule])';
23
- const nodes = tsquery(ast, NG_MODULE_DECORATOR_SELECTOR, {
24
- visitAllChildren: true,
25
- });
26
- if (nodes.length === 0) {
27
- throw new Error(`The provided parent path "${options.parent}" does not contain an "NgModule". ` +
28
- 'Please make sure to provide a path to an "NgModule" where the state will be registered. ' +
29
- 'If you are trying to use a "Routes" definition file (for Standalone API usage), ' +
30
- 'please note this is not supported in Angular versions lower than 14.1.0.');
31
- }
32
- }
33
11
  }
34
12
  exports.validateOptions = validateOptions;
@@ -18,13 +18,13 @@
18
18
  },
19
19
  "parent": {
20
20
  "type": "string",
21
- "description": "The path to the file where the state will be registered. For NgModule usage, this will be your Feature Module. For Standalone API usage, this will be your Routes definition file for your feature state. The host directory will create/use the new state directory. _Note: The Standalone API usage is only supported in Angular versions >= 14.1.0_.",
21
+ "description": "The path to the file where the state will be registered. For NgModule usage, this will be your Feature Module. For Standalone API usage, this will be your Routes definition file for your feature state. The host directory will create/use the new state directory.",
22
22
  "x-prompt": "What is the path to the module or Routes definition where this NgRx state should be registered?",
23
23
  "x-priority": "important"
24
24
  },
25
25
  "route": {
26
26
  "type": "string",
27
- "description": "The route that the Standalone NgRx Providers should be added to. _Note: This is only supported in Angular versions >= 14.1.0_.",
27
+ "description": "The route that the Standalone NgRx Providers should be added to.",
28
28
  "default": "''"
29
29
  },
30
30
  "minimal": {
@@ -16,7 +16,7 @@ function normalizeOptions(tree, options) {
16
16
  const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
17
17
  const isStandalone = (0, ast_utils_1.isNgStandaloneApp)(tree, options.project);
18
18
  const appConfigPath = (0, devkit_1.joinPathFragments)(project.sourceRoot, 'app/app.config.ts');
19
- const appMainPath = project.targets.build.options.main;
19
+ const appMainPath = project.targets.build.options.main ?? project.targets.build.options.browser;
20
20
  /** If NgModule App
21
21
  * -> Use App Module
22
22
  * If Standalone
@@ -2,10 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateOptions = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const version_utils_1 = require("../../utils/version-utils");
6
- const version_utils_2 = require("../../../utils/version-utils");
7
- const semver_1 = require("semver");
8
- const ast_utils_1 = require("../../../utils/nx-devkit/ast-utils");
9
5
  function validateOptions(tree, options) {
10
6
  if (!(0, devkit_1.getProjects)(tree).has(options.project)) {
11
7
  throw new Error(`Could not find project '${options.project}'. Please ensure the project name is correct and exists.`);
@@ -17,16 +13,5 @@ function validateOptions(tree, options) {
17
13
  if (!options.minimal && !options.name) {
18
14
  throw new Error(`If generating a global feature state with your root store, you must provide a name for it with '--name'.`);
19
15
  }
20
- const angularVersionInfo = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
21
- const intendedNgRxVersionForAngularMajor = (0, version_utils_2.getPkgVersionForAngularMajorVersion)('ngrxVersion', angularVersionInfo.major);
22
- const ngrxMajorVersion = (0, version_utils_1.getInstalledPackageVersionInfo)(tree, '@ngrx/store')?.major ??
23
- (0, semver_1.major)((0, semver_1.coerce)(intendedNgRxVersionForAngularMajor));
24
- const isStandalone = (0, ast_utils_1.isNgStandaloneApp)(tree, options.project);
25
- if ((0, semver_1.lt)(angularVersionInfo.version, '14.1.0') || ngrxMajorVersion < 15) {
26
- if (isStandalone) {
27
- throw new Error(`The provided project '${options.project}' is set up to use Standalone APIs, however your workspace is not configured to support Standalone APIs. ` +
28
- 'Please make sure to provide a path to an "NgModule" where the state will be registered. ');
29
- }
30
- }
31
16
  }
32
17
  exports.validateOptions = validateOptions;
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "route": {
31
31
  "type": "string",
32
- "description": "The route that the Standalone NgRx Providers should be added to. _Note: This is only supported in Angular versions >= 14.1.0_.",
32
+ "description": "The route that the Standalone NgRx Providers should be added to.",
33
33
  "default": "''"
34
34
  },
35
35
  "directory": {
@@ -1,2 +1 @@
1
1
  export * from './normalize-options';
2
- export * from './validate-options';
@@ -2,4 +2,3 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./normalize-options"), exports);
5
- tslib_1.__exportStar(require("./validate-options"), exports);
@@ -25,6 +25,7 @@ async function normalizeOptions(tree, options) {
25
25
  fileName,
26
26
  filePath,
27
27
  symbolName,
28
+ standalone: options.standalone ?? true,
28
29
  };
29
30
  }
30
31
  exports.normalizeOptions = normalizeOptions;
@@ -5,7 +5,6 @@ const devkit_1 = require("@nx/devkit");
5
5
  const utils_1 = require("../utils");
6
6
  const lib_1 = require("./lib");
7
7
  async function pipeGenerator(tree, rawOptions) {
8
- (0, lib_1.validateOptions)(tree, rawOptions);
9
8
  const options = await (0, lib_1.normalizeOptions)(tree, rawOptions);
10
9
  const pipeNames = (0, devkit_1.names)(options.name);
11
10
  (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files'), options.directory, {
@@ -53,9 +53,9 @@
53
53
  "description": "Do not import this pipe into the owning NgModule."
54
54
  },
55
55
  "standalone": {
56
- "description": "Whether the generated pipe is standalone. _Note: This is only supported in Angular versions >= 14.1.0_.",
56
+ "description": "Whether the generated pipe is standalone.",
57
57
  "type": "boolean",
58
- "default": false
58
+ "default": true
59
59
  },
60
60
  "module": {
61
61
  "type": "string",
@@ -0,0 +1,74 @@
1
+ import 'zone.js/node';
2
+
3
+ import { APP_BASE_HREF } from '@angular/common';
4
+ import { CommonEngine } from '@angular/ssr';
5
+ import * as express from 'express';
6
+ import * as cors from 'cors';
7
+ import { existsSync } from 'node:fs';
8
+ import { join } from 'node:path';
9
+ import<% if(standalone) { %> bootstrap <% } else { %> { AppServerModule } <% } %>from './bootstrap.server';
10
+
11
+ // The Express app is exported so that it can be used by serverless Functions.
12
+ export function app(): express.Express {
13
+ const server = express();
14
+ const browserBundles = join(process.cwd(), '<%= browserBundleOutput %>');
15
+ const serverBundles = join(process.cwd(), '<%= serverBundleOutput %>');
16
+ const indexHtml = existsSync(join(browserBundles, 'index.original.html'))
17
+ ? join(browserBundles, 'index.original.html')
18
+ : join(browserBundles, 'index.html');
19
+
20
+ server.use(cors());
21
+
22
+ const commonEngine = new CommonEngine();
23
+
24
+ server.set('view engine', 'html');
25
+ server.set('views', browserBundles);
26
+
27
+
28
+ // Example Express Rest API endpoints
29
+ // server.get('/api/**', (req, res) => { });
30
+ // Serve static files from /browser
31
+ server.use('/', express.static(browserBundles, { maxAge: '1y' }));
32
+ // Serve static files from /server
33
+ server.use('/server', express.static(serverBundles, { maxAge: '1y' }));
34
+
35
+ // All regular routes use the Angular engine
36
+ server.get('*', (req, res, next) => {
37
+ const { protocol, originalUrl, baseUrl, headers } = req;
38
+
39
+ commonEngine
40
+ .render({
41
+ bootstrap<% if (!standalone) { %>: AppServerModule<% } %>,
42
+ documentFilePath: indexHtml,
43
+ url: `${protocol}://${headers.host}${originalUrl}`,
44
+ publicPath: browserBundles,
45
+ providers: [{ provide: APP_BASE_HREF, useValue: baseUrl }],
46
+ })
47
+ .then((html) => res.send(html))
48
+ .catch((err) => next(err));
49
+ });
50
+
51
+ return server;
52
+ }
53
+
54
+ function run(): void {
55
+ const port = process.env['PORT'] || 4000;
56
+
57
+ // Start up the Node server
58
+ const server = app();
59
+ server.listen(port, () => {
60
+ console.log(`Node Express server listening on http://localhost:${port}`);
61
+
62
+ /**
63
+ * DO NOT REMOVE IF USING @nx/angular:module-federation-dev-ssr executor
64
+ * to serve your Host application with this Remote application.
65
+ * This message allows Nx to determine when the Remote is ready to be
66
+ * consumed by the Host.
67
+ */
68
+ process.send && process.send('nx.server.ready');
69
+ });
70
+ }
71
+
72
+ run();
73
+
74
+ export default <% if (standalone) { %>bootstrap<% } else { %>AppServerModule<% } %>;
@@ -1,2 +1,2 @@
1
1
  export * from './find-next-available-port';
2
- export * from './add-ssr';
2
+ export * from './update-ssr-setup';
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./find-next-available-port"), exports);
5
- tslib_1.__exportStar(require("./add-ssr"), exports);
5
+ tslib_1.__exportStar(require("./update-ssr-setup"), exports);
@@ -1,5 +1,5 @@
1
1
  import type { Tree } from '@nx/devkit';
2
- export declare function addSsr(tree: Tree, { appName, port, standalone, typescriptConfiguration, }: {
2
+ export declare function updateSsrSetup(tree: Tree, { appName, port, standalone, typescriptConfiguration, }: {
3
3
  appName: string;
4
4
  port: number;
5
5
  standalone: boolean;