@nx/angular 20.2.0-canary.20241130-ec5a5e6 → 20.2.0-canary.20241204-75b2080
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.
- package/executors.json +1 -1
- package/fesm2022/nx-angular-mf.mjs.map +1 -1
- package/fesm2022/nx-angular-testing.mjs.map +1 -1
- package/fesm2022/nx-angular.mjs.map +1 -1
- package/generators.json +1 -1
- package/migrations.json +160 -1
- package/package.json +12 -19
- package/src/builders/dev-server/lib/normalize-options.js +3 -0
- package/src/builders/dev-server/lib/validate-options.js +1 -9
- package/src/builders/dev-server/schema.json +3 -4
- package/src/executors/application/application.impl.d.ts +1 -1
- package/src/executors/application/application.impl.js +4 -1
- package/src/executors/application/schema.json +78 -6
- package/src/executors/application/utils/normalize-options.d.ts +2 -0
- package/src/executors/application/utils/normalize-options.js +33 -0
- package/src/executors/application/utils/validate-options.js +18 -4
- package/src/executors/browser-esbuild/browser-esbuild.impl.d.ts +1 -1
- package/src/executors/browser-esbuild/browser-esbuild.impl.js +0 -9
- package/src/executors/browser-esbuild/schema.json +1 -1
- package/src/executors/delegate-build/delegate-build.impl.d.ts +1 -1
- package/src/executors/module-federation-dev-server/lib/index.d.ts +0 -2
- package/src/executors/module-federation-dev-server/lib/index.js +0 -2
- package/src/executors/module-federation-dev-server/lib/normalize-options.js +1 -0
- package/src/executors/module-federation-dev-server/lib/start-dev-remotes.d.ts +1 -1
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +1 -1
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +2 -26
- package/src/executors/module-federation-dev-server/schema.d.ts +1 -0
- package/src/executors/module-federation-ssr-dev-server/lib/normalize-options.d.ts +2 -2
- package/src/executors/module-federation-ssr-dev-server/lib/normalize-options.js +1 -0
- package/src/executors/module-federation-ssr-dev-server/lib/start-dev-remotes.d.ts +1 -1
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.d.ts +1 -1
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +7 -33
- package/src/executors/module-federation-ssr-dev-server/schema.d.ts +8 -14
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-packagr.d.ts +1 -2
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-packagr.js +11 -20
- package/src/executors/ng-packagr-lite/ng-packagr-lite.impl.d.ts +1 -1
- package/src/executors/ng-packagr-lite/ng-packagr-lite.impl.js +1 -1
- package/src/executors/ng-packagr-lite/schema.json +0 -8
- package/src/executors/package/ng-packagr-adjustments/ng-packagr.d.ts +1 -2
- package/src/executors/package/ng-packagr-adjustments/ng-packagr.js +4 -21
- package/src/executors/package/package.impl.d.ts +2 -2
- package/src/executors/package/package.impl.js +1 -1
- package/src/executors/package/schema.d.ts +1 -3
- package/src/executors/package/schema.json +0 -10
- package/src/executors/utilities/ng-packagr/{stylesheet-processor.js → pre-v19/stylesheet-processor.js} +2 -2
- package/src/executors/utilities/ng-packagr/stylesheet-processor.di.js +11 -5
- package/src/executors/utilities/ng-packagr/tailwindcss.d.ts +0 -6
- package/src/executors/utilities/ng-packagr/tailwindcss.js +0 -32
- package/src/executors/utilities/ng-packagr/v19+/stylesheet-processor.d.ts +23 -0
- package/src/executors/utilities/ng-packagr/v19+/stylesheet-processor.js +93 -0
- package/src/generators/application/application.js +1 -0
- package/src/generators/application/files/ng-module/src/app/app.component.ts__tpl__ +4 -5
- package/src/generators/application/files/nx-welcome/claimed/ng-module/src/app/nx-welcome.component.ts__tpl__ +2 -1
- package/src/generators/application/files/nx-welcome/claimed/standalone/src/app/nx-welcome.component.ts__tpl__ +2 -2
- package/src/generators/application/files/nx-welcome/not-configured/ng-module/src/app/nx-welcome.component.ts__tpl__ +2 -1
- package/src/generators/application/files/nx-welcome/not-configured/standalone/src/app/nx-welcome.component.ts__tpl__ +2 -2
- package/src/generators/application/files/nx-welcome/unclaimed/ng-module/src/app/nx-welcome.component.ts__tpl__ +2 -1
- package/src/generators/application/files/nx-welcome/unclaimed/standalone/src/app/nx-welcome.component.ts__tpl__ +2 -2
- package/src/generators/application/files/standalone-components/src/app/app.component.ts__tpl__ +4 -6
- package/src/generators/application/lib/add-serve-static-target.d.ts +1 -1
- package/src/generators/application/lib/add-serve-static-target.js +1 -3
- package/src/generators/application/lib/create-files.js +4 -1
- package/src/generators/application/lib/create-project.js +24 -31
- package/src/generators/application/lib/normalize-options.js +1 -6
- package/src/generators/application/schema.d.ts +1 -0
- package/src/generators/application/schema.json +7 -2
- package/src/generators/component/component.js +4 -0
- package/src/generators/component/files/__fileName__.spec.ts__tpl__ +1 -1
- package/src/generators/component/files/__fileName__.ts__tpl__ +5 -13
- package/src/generators/component/lib/normalize-options.js +2 -0
- package/src/generators/component/schema.d.ts +1 -0
- package/src/generators/component/schema.json +5 -0
- package/src/generators/convert-to-application-executor/convert-to-application-executor.js +1 -4
- package/src/generators/convert-to-application-executor/schema.json +1 -1
- package/src/generators/directive/directive.js +5 -0
- package/src/generators/directive/files/__fileName__.ts__tpl__ +2 -2
- package/src/generators/directive/lib/normalize-options.js +3 -1
- package/src/generators/host/files/common/{v17+/src → src}/main.server.ts__tmpl__ +1 -1
- package/src/generators/host/lib/update-ssr-setup.js +2 -1
- package/src/generators/host/schema.d.ts +1 -0
- package/src/generators/host/schema.json +4 -0
- package/src/generators/pipe/files/__fileName__.ts__tpl__ +2 -2
- package/src/generators/pipe/lib/normalize-options.js +3 -1
- package/src/generators/pipe/pipe.js +5 -0
- package/src/generators/remote/files/common/{v17+/src → src}/main.server.ts__tmpl__ +1 -1
- package/src/generators/remote/lib/update-ssr-setup.js +2 -1
- package/src/generators/remote/schema.d.ts +1 -0
- package/src/generators/remote/schema.json +4 -0
- package/src/generators/scam/lib/normalize-options.js +3 -1
- package/src/generators/scam-directive/lib/normalize-options.js +3 -1
- package/src/generators/scam-pipe/lib/normalize-options.js +3 -1
- package/src/generators/scam-to-standalone/lib/convert-scam-to-standalone.d.ts +1 -1
- package/src/generators/scam-to-standalone/lib/convert-scam-to-standalone.js +5 -4
- package/src/generators/setup-mf/files/entry-module-files/entry.component.ts__tmpl__ +2 -1
- package/src/generators/setup-mf/files/standalone-entry-component-files/entry.component.ts__tmpl__ +2 -2
- package/src/generators/setup-mf/lib/add-remote-entry.js +5 -0
- package/src/generators/setup-ssr/files/{server → pre-v19/server}/application-builder/__serverFileName__ +1 -1
- package/src/generators/setup-ssr/files/{server/server-builder/v17+ → pre-v19/server/server-builder}/__serverFileName__ +1 -1
- package/src/generators/setup-ssr/files/v19+/application-builder/ngmodule-src/__main__ +1 -0
- package/src/generators/setup-ssr/files/v19+/application-builder/ngmodule-src/app/__rootModuleFileName__ +13 -0
- package/src/generators/setup-ssr/files/v19+/application-builder/ngmodule-src/app/app.routes.server.ts__tpl__ +8 -0
- package/src/generators/setup-ssr/files/v19+/application-builder/server/__serverFileName__ +66 -0
- package/src/generators/setup-ssr/files/v19+/application-builder/standalone-src/__main__ +7 -0
- package/src/generators/setup-ssr/files/v19+/application-builder/standalone-src/app/app.config.server.ts__tpl__ +14 -0
- package/src/generators/setup-ssr/files/v19+/application-builder/standalone-src/app/app.routes.server.ts__tpl__ +8 -0
- package/src/generators/setup-ssr/files/v19+/application-builder-common-engine/server/__serverFileName__ +65 -0
- package/src/generators/setup-ssr/files/v19+/server-builder/ngmodule-src/__main__ +1 -0
- package/src/generators/setup-ssr/files/v19+/server-builder/ngmodule-src/app/__rootModuleFileName__ +14 -0
- package/src/generators/setup-ssr/files/v19+/server-builder/root/tsconfig.server.json.template +16 -0
- package/src/generators/setup-ssr/files/{server/server-builder/pre-v17 → v19+/server-builder/server}/__serverFileName__ +25 -15
- package/src/generators/setup-ssr/files/v19+/server-builder/standalone-src/__main__ +7 -0
- package/src/generators/setup-ssr/files/v19+/server-builder/standalone-src/app/app.config.server.ts.template +11 -0
- package/src/generators/setup-ssr/lib/add-dependencies.js +6 -17
- package/src/generators/setup-ssr/lib/add-hydration.d.ts +2 -2
- package/src/generators/setup-ssr/lib/add-hydration.js +10 -2
- package/src/generators/setup-ssr/lib/add-server-file.d.ts +2 -2
- package/src/generators/setup-ssr/lib/add-server-file.js +24 -10
- package/src/generators/setup-ssr/lib/generate-files.d.ts +2 -2
- package/src/generators/setup-ssr/lib/generate-files.js +20 -8
- package/src/generators/setup-ssr/lib/generate-server-ts-config.d.ts +3 -3
- package/src/generators/setup-ssr/lib/generate-server-ts-config.js +24 -3
- package/src/generators/setup-ssr/lib/normalize-options.d.ts +3 -14
- package/src/generators/setup-ssr/lib/normalize-options.js +23 -6
- package/src/generators/setup-ssr/lib/set-router-initial-navigation.d.ts +2 -2
- package/src/generators/setup-ssr/lib/update-project-config.d.ts +3 -3
- package/src/generators/setup-ssr/lib/update-project-config.js +36 -24
- package/src/generators/setup-ssr/lib/validate-options.js +5 -0
- package/src/generators/setup-ssr/schema.d.ts +5 -0
- package/src/generators/setup-ssr/schema.json +6 -8
- package/src/generators/setup-ssr/setup-ssr.js +6 -11
- package/src/generators/setup-tailwind/lib/index.d.ts +1 -1
- package/src/generators/setup-tailwind/lib/index.js +1 -1
- package/src/generators/setup-tailwind/lib/update-application-styles.js +1 -1
- package/src/generators/setup-tailwind/lib/validate-build-target.d.ts +3 -0
- package/src/generators/setup-tailwind/lib/{add-tailwind-config-path-to-project.js → validate-build-target.js} +4 -15
- package/src/generators/setup-tailwind/setup-tailwind.js +4 -1
- package/src/generators/utils/add-jest.js +4 -8
- package/src/generators/utils/storybook-ast/component-info.js +12 -2
- package/src/generators/utils/validations.d.ts +1 -0
- package/src/generators/utils/validations.js +10 -0
- package/src/generators/utils/version-utils.js +2 -2
- package/src/migrations/update-20-2-0/add-localize-polyfill-to-targets.d.ts +3 -0
- package/src/migrations/update-20-2-0/add-localize-polyfill-to-targets.js +48 -0
- package/src/migrations/update-20-2-0/disable-angular-eslint-prefer-standalone.d.ts +2 -0
- package/src/migrations/update-20-2-0/disable-angular-eslint-prefer-standalone.js +55 -0
- package/src/migrations/update-20-2-0/update-angular-cli.d.ts +3 -0
- package/src/migrations/update-20-2-0/update-angular-cli.js +23 -0
- package/src/migrations/update-20-2-0/update-angular-ssr-imports-to-use-node-entry-point.d.ts +2 -0
- package/src/migrations/update-20-2-0/update-angular-ssr-imports-to-use-node-entry-point.js +55 -0
- package/src/utils/backward-compatible-versions.d.ts +4 -4
- package/src/utils/backward-compatible-versions.js +20 -19
- package/src/utils/nx-devkit/ast-utils.d.ts +10 -1
- package/src/utils/nx-devkit/ast-utils.js +32 -9
- package/src/utils/versions.d.ts +7 -7
- package/src/utils/versions.js +7 -7
- package/esm2022/index.mjs +0 -2
- package/esm2022/mf/index.mjs +0 -2
- package/esm2022/mf/mf.mjs +0 -116
- package/esm2022/mf/nx-angular-mf.mjs +0 -5
- package/esm2022/nx-angular.mjs +0 -5
- package/esm2022/src/runtime/nx/data-persistence.mjs +0 -349
- package/esm2022/testing/index.mjs +0 -2
- package/esm2022/testing/nx-angular-testing.mjs +0 -5
- package/esm2022/testing/src/testing-utils.mjs +0 -38
- package/src/executors/module-federation-dev-server/lib/build-static-remotes.d.ts +0 -4
- package/src/executors/module-federation-dev-server/lib/build-static-remotes.js +0 -65
- package/src/executors/module-federation-dev-server/lib/start-static-remotes-file-server.d.ts +0 -9
- package/src/executors/module-federation-dev-server/lib/start-static-remotes-file-server.js +0 -51
- package/src/executors/module-federation-ssr-dev-server/lib/build-static-remotes.d.ts +0 -4
- package/src/executors/module-federation-ssr-dev-server/lib/build-static-remotes.js +0 -65
- package/src/executors/module-federation-ssr-dev-server/lib/start-static-remotes.d.ts +0 -4
- package/src/executors/module-federation-ssr-dev-server/lib/start-static-remotes.js +0 -41
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ng-package/entry-point/compile-ngc.di.d.ts +0 -14
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ng-package/entry-point/compile-ngc.di.js +0 -27
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ng-package/entry-point/compile-ngc.transform.d.ts +0 -12
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ng-package/entry-point/compile-ngc.transform.js +0 -53
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ng-package/entry-point/entry-point.di.d.ts +0 -15
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ng-package/entry-point/entry-point.di.js +0 -28
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ng-package/entry-point/entry-point.transform.d.ts +0 -30
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ng-package/entry-point/entry-point.transform.js +0 -52
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ng-package/entry-point/write-package.di.d.ts +0 -12
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ng-package/entry-point/write-package.di.js +0 -20
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ng-package/entry-point/write-package.transform.d.ts +0 -9
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ng-package/entry-point/write-package.transform.js +0 -320
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ng-package/options.di.d.ts +0 -14
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ng-package/options.di.js +0 -35
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ng-package/package.di.d.ts +0 -14
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ng-package/package.di.js +0 -37
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ngc/compile-source-files.d.ts +0 -12
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/ngc/compile-source-files.js +0 -178
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/styles/stylesheet-processor.d.ts +0 -42
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/styles/stylesheet-processor.di.d.ts +0 -10
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/styles/stylesheet-processor.di.js +0 -17
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/pre-v17/styles/stylesheet-processor.js +0 -201
- package/src/executors/package/ng-packagr-adjustments/ng-package/entry-point/compile-ngc.di.d.ts +0 -14
- package/src/executors/package/ng-packagr-adjustments/ng-package/entry-point/compile-ngc.di.js +0 -26
- package/src/executors/package/ng-packagr-adjustments/ng-package/entry-point/compile-ngc.transform.d.ts +0 -12
- package/src/executors/package/ng-packagr-adjustments/ng-package/entry-point/compile-ngc.transform.js +0 -71
- package/src/executors/package/ng-packagr-adjustments/ng-package/entry-point/entry-point.di.d.ts +0 -13
- package/src/executors/package/ng-packagr-adjustments/ng-package/entry-point/entry-point.di.js +0 -32
- package/src/executors/package/ng-packagr-adjustments/ng-package/options.di.d.ts +0 -14
- package/src/executors/package/ng-packagr-adjustments/ng-package/options.di.js +0 -35
- package/src/executors/package/ng-packagr-adjustments/ng-package/package.di.d.ts +0 -14
- package/src/executors/package/ng-packagr-adjustments/ng-package/package.di.js +0 -37
- package/src/executors/package/ng-packagr-adjustments/ngc/compile-source-files.d.ts +0 -13
- package/src/executors/package/ng-packagr-adjustments/ngc/compile-source-files.js +0 -183
- package/src/executors/package/ng-packagr-adjustments/styles/stylesheet-processor.d.ts +0 -36
- package/src/executors/package/ng-packagr-adjustments/styles/stylesheet-processor.di.d.ts +0 -10
- package/src/executors/package/ng-packagr-adjustments/styles/stylesheet-processor.di.js +0 -17
- package/src/executors/package/ng-packagr-adjustments/styles/stylesheet-processor.js +0 -194
- package/src/executors/package/ng-packagr-adjustments/utils/ng-compiler-cli.d.ts +0 -1
- package/src/executors/package/ng-packagr-adjustments/utils/ng-compiler-cli.js +0 -9
- package/src/generators/host/files/common/pre-v17/src/main.server.ts__tmpl__ +0 -66
- package/src/generators/remote/files/common/pre-v17/src/main.server.ts__tmpl__ +0 -72
- package/src/generators/setup-tailwind/lib/add-tailwind-config-path-to-project.d.ts +0 -3
- /package/src/executors/ng-packagr-lite/ng-packagr-adjustments/{v17+ → pre-v19}/ng-package/entry-point/write-bundles.di.d.ts +0 -0
- /package/src/executors/ng-packagr-lite/ng-packagr-adjustments/{v17+ → pre-v19}/ng-package/entry-point/write-bundles.di.js +0 -0
- /package/src/executors/ng-packagr-lite/ng-packagr-adjustments/{v17+ → pre-v19}/ng-package/entry-point/write-bundles.transform.d.ts +0 -0
- /package/src/executors/ng-packagr-lite/ng-packagr-adjustments/{v17+ → pre-v19}/ng-package/entry-point/write-bundles.transform.js +0 -0
- /package/src/executors/ng-packagr-lite/ng-packagr-adjustments/{v17+ → pre-v19}/ng-package/entry-point/write-package.di.d.ts +0 -0
- /package/src/executors/ng-packagr-lite/ng-packagr-adjustments/{v17+ → pre-v19}/ng-package/entry-point/write-package.di.js +0 -0
- /package/src/executors/ng-packagr-lite/ng-packagr-adjustments/{v17+ → pre-v19}/ng-package/entry-point/write-package.transform.d.ts +0 -0
- /package/src/executors/ng-packagr-lite/ng-packagr-adjustments/{v17+ → pre-v19}/ng-package/entry-point/write-package.transform.js +0 -0
- /package/src/executors/utilities/ng-packagr/{stylesheet-processor.d.ts → pre-v19/stylesheet-processor.d.ts} +0 -0
- /package/src/generators/setup-ssr/files/{ngmodule/src → pre-v19/ngmodule-src}/__main__ +0 -0
- /package/src/generators/setup-ssr/files/{ngmodule/src → pre-v19/ngmodule-src}/app/__rootModuleFileName__ +0 -0
- /package/src/generators/setup-ssr/files/{root → pre-v19/root}/tsconfig.server.json__tpl__ +0 -0
- /package/src/generators/setup-ssr/files/{standalone/src → pre-v19/standalone-src}/__main__ +0 -0
- /package/src/generators/setup-ssr/files/{standalone/src → pre-v19/standalone-src}/app/app.config.server.ts__tpl__ +0 -0
|
@@ -4,6 +4,7 @@ exports.normalizeOptions = normalizeOptions;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
6
6
|
const selector_1 = require("../../utils/selector");
|
|
7
|
+
const validations_1 = require("../../utils/validations");
|
|
7
8
|
async function normalizeOptions(tree, options) {
|
|
8
9
|
options.type ??= 'component';
|
|
9
10
|
const { artifactName: name, directory, fileName, filePath, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
|
|
@@ -14,6 +15,7 @@ async function normalizeOptions(tree, options) {
|
|
|
14
15
|
const { className } = (0, devkit_1.names)(name);
|
|
15
16
|
const { className: suffixClassName } = (0, devkit_1.names)(options.type);
|
|
16
17
|
const symbolName = `${className}${suffixClassName}`;
|
|
18
|
+
(0, validations_1.validateClassName)(symbolName);
|
|
17
19
|
const { prefix, root, sourceRoot } = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
18
20
|
const selector = options.selector ?? (0, selector_1.buildSelector)(name, options.prefix, prefix, 'fileName');
|
|
19
21
|
(0, selector_1.validateHtmlSelector)(selector);
|
|
@@ -104,6 +104,11 @@
|
|
|
104
104
|
"default": false,
|
|
105
105
|
"x-priority": "important"
|
|
106
106
|
},
|
|
107
|
+
"exportDefault": {
|
|
108
|
+
"type": "boolean",
|
|
109
|
+
"default": false,
|
|
110
|
+
"description": "Use default export for the component instead of a named export."
|
|
111
|
+
},
|
|
107
112
|
"skipFormat": {
|
|
108
113
|
"description": "Skip formatting files.",
|
|
109
114
|
"type": "boolean",
|
|
@@ -26,10 +26,7 @@ const redundantExecutors = new Set([
|
|
|
26
26
|
'@nx/angular:webpack-server',
|
|
27
27
|
]);
|
|
28
28
|
async function convertToApplicationExecutor(tree, options) {
|
|
29
|
-
const {
|
|
30
|
-
if (angularMajorVersion < 17) {
|
|
31
|
-
throw new Error(`The "convert-to-application-executor" generator is only supported in Angular >= 17.0.0. You are currently using "${angularVersion}".`);
|
|
32
|
-
}
|
|
29
|
+
const { version: angularVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
33
30
|
let didAnySucceed = false;
|
|
34
31
|
if (options.project) {
|
|
35
32
|
(0, validations_1.validateProject)(tree, options.project);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "http://json-schema.org/schema",
|
|
3
3
|
"$id": "NxAngularConvertToApplicationExecutorGenerator",
|
|
4
4
|
"cli": "nx",
|
|
5
|
-
"title": "Converts projects to use the `@nx/angular:application` executor or the `@angular-devkit/build-angular:application` builder.
|
|
5
|
+
"title": "Converts projects to use the `@nx/angular:application` executor or the `@angular-devkit/build-angular:application` builder.",
|
|
6
6
|
"description": "Converts a project or all projects using one of the `@angular-devkit/build-angular:browser`, `@angular-devkit/build-angular:browser-esbuild`, `@nx/angular:browser` and `@nx/angular:browser-esbuild` executors to use the `@nx/angular:application` executor or the `@angular-devkit/build-angular:application` builder. If the converted target is using one of the `@nx/angular` executors, the `@nx/angular:application` executor will be used. Otherwise, the `@angular-devkit/build-angular:application` builder will be used.",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"properties": {
|
|
@@ -3,14 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.directiveGenerator = directiveGenerator;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
+
const version_utils_1 = require("../utils/version-utils");
|
|
6
7
|
const lib_1 = require("./lib");
|
|
7
8
|
async function directiveGenerator(tree, schema) {
|
|
8
9
|
const options = await (0, lib_1.normalizeOptions)(tree, schema);
|
|
10
|
+
const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
9
11
|
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files'), options.directory, {
|
|
10
12
|
selector: options.selector,
|
|
11
13
|
symbolName: options.symbolName,
|
|
12
14
|
fileName: options.fileName,
|
|
13
15
|
standalone: options.standalone,
|
|
16
|
+
// Angular v19 or higher defaults to true, while v18 or lower defaults to false
|
|
17
|
+
setStandalone: (angularMajorVersion >= 19 && !options.standalone) ||
|
|
18
|
+
(angularMajorVersion < 19 && options.standalone),
|
|
14
19
|
tpl: '',
|
|
15
20
|
});
|
|
16
21
|
if (options.skipTests) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Directive } from '@angular/core';
|
|
2
2
|
|
|
3
3
|
@Directive({
|
|
4
|
-
selector: '[<%= selector %>]'<% if(
|
|
5
|
-
standalone:
|
|
4
|
+
selector: '[<%= selector %>]'<% if (setStandalone) { %>,
|
|
5
|
+
standalone: <%= standalone %><% } %>
|
|
6
6
|
})
|
|
7
7
|
export class <%= symbolName %> {
|
|
8
8
|
constructor() {}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = normalizeOptions;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const selector_1 = require("../../utils/selector");
|
|
6
5
|
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
6
|
+
const selector_1 = require("../../utils/selector");
|
|
7
|
+
const validations_1 = require("../../utils/validations");
|
|
7
8
|
async function normalizeOptions(tree, options) {
|
|
8
9
|
const { artifactName: name, directory, fileName, filePath, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
|
|
9
10
|
name: options.name,
|
|
@@ -13,6 +14,7 @@ async function normalizeOptions(tree, options) {
|
|
|
13
14
|
const { className } = (0, devkit_1.names)(name);
|
|
14
15
|
const { className: suffixClassName } = (0, devkit_1.names)('directive');
|
|
15
16
|
const symbolName = `${className}${suffixClassName}`;
|
|
17
|
+
(0, validations_1.validateClassName)(symbolName);
|
|
16
18
|
const { prefix } = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
17
19
|
const selector = options.selector ??
|
|
18
20
|
(0, selector_1.buildSelector)(name, options.prefix, prefix, 'propertyName');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'zone.js/node';
|
|
2
2
|
|
|
3
3
|
import { APP_BASE_HREF } from '@angular/common';
|
|
4
|
-
import { CommonEngine } from '
|
|
4
|
+
import { CommonEngine } from '<%= commonEngineEntryPoint %>';
|
|
5
5
|
import * as express from 'express';
|
|
6
6
|
import * as cors from 'cors';
|
|
7
7
|
import { existsSync } from 'node:fs';
|
|
@@ -10,10 +10,11 @@ async function updateSsrSetup(tree, options, appName, typescriptConfiguration) {
|
|
|
10
10
|
tree.rename((0, devkit_1.joinPathFragments)(project.sourceRoot, 'main.server.ts'), (0, devkit_1.joinPathFragments)(project.sourceRoot, 'bootstrap.server.ts'));
|
|
11
11
|
tree.write((0, devkit_1.joinPathFragments)(project.root, 'server.ts'), "import('./src/main.server');");
|
|
12
12
|
const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
13
|
-
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, '../files/common'
|
|
13
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, '../files/common'), project.root, {
|
|
14
14
|
appName,
|
|
15
15
|
browserBundleOutput: project.targets.build.options.outputPath,
|
|
16
16
|
standalone: options.standalone,
|
|
17
|
+
commonEngineEntryPoint: angularMajorVersion >= 19 ? '@angular/ssr/node' : '@angular/ssr',
|
|
17
18
|
tmpl: '',
|
|
18
19
|
});
|
|
19
20
|
const pathToTemplateFiles = typescriptConfiguration ? 'ts' : 'js';
|
|
@@ -172,6 +172,10 @@
|
|
|
172
172
|
"default": false,
|
|
173
173
|
"x-priority": "important"
|
|
174
174
|
},
|
|
175
|
+
"serverRouting": {
|
|
176
|
+
"description": "Creates a server application using the Server Routing and App Engine APIs (Developer Preview). _Note: this is only supported in Angular versions >= 19.0.0_.",
|
|
177
|
+
"type": "boolean"
|
|
178
|
+
},
|
|
175
179
|
"typescriptConfiguration": {
|
|
176
180
|
"type": "boolean",
|
|
177
181
|
"description": "Whether the module federation configuration and webpack configuration files should use TS.",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Pipe, PipeTransform } from '@angular/core';
|
|
2
2
|
|
|
3
3
|
@Pipe({
|
|
4
|
-
name: '<%= selector %>'<% if(
|
|
5
|
-
standalone:
|
|
4
|
+
name: '<%= selector %>'<% if (setStandalone) { %>,
|
|
5
|
+
standalone: <%= standalone %><% } %>
|
|
6
6
|
})
|
|
7
7
|
export class <%= symbolName %> implements PipeTransform {
|
|
8
8
|
transform(value: unknown, ...args: unknown[]): unknown {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = normalizeOptions;
|
|
4
|
-
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
6
|
+
const validations_1 = require("../../utils/validations");
|
|
6
7
|
async function normalizeOptions(tree, options) {
|
|
7
8
|
const { artifactName: name, directory, fileName, filePath, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
|
|
8
9
|
name: options.name,
|
|
@@ -12,6 +13,7 @@ async function normalizeOptions(tree, options) {
|
|
|
12
13
|
const { className } = (0, devkit_1.names)(name);
|
|
13
14
|
const { className: suffixClassName } = (0, devkit_1.names)('pipe');
|
|
14
15
|
const symbolName = `${className}${suffixClassName}`;
|
|
16
|
+
(0, validations_1.validateClassName)(symbolName);
|
|
15
17
|
return {
|
|
16
18
|
...options,
|
|
17
19
|
projectName,
|
|
@@ -3,15 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.pipeGenerator = pipeGenerator;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
+
const version_utils_1 = require("../utils/version-utils");
|
|
6
7
|
const lib_1 = require("./lib");
|
|
7
8
|
async function pipeGenerator(tree, rawOptions) {
|
|
8
9
|
const options = await (0, lib_1.normalizeOptions)(tree, rawOptions);
|
|
10
|
+
const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
9
11
|
const pipeNames = (0, devkit_1.names)(options.name);
|
|
10
12
|
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files'), options.directory, {
|
|
11
13
|
symbolName: options.symbolName,
|
|
12
14
|
fileName: options.fileName,
|
|
13
15
|
selector: pipeNames.propertyName,
|
|
14
16
|
standalone: options.standalone,
|
|
17
|
+
// Angular v19 or higher defaults to true, while v18 or lower defaults to false
|
|
18
|
+
setStandalone: (angularMajorVersion >= 19 && !options.standalone) ||
|
|
19
|
+
(angularMajorVersion < 19 && options.standalone),
|
|
15
20
|
tpl: '',
|
|
16
21
|
});
|
|
17
22
|
if (options.skipTests) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'zone.js/node';
|
|
2
2
|
|
|
3
3
|
import { APP_BASE_HREF } from '@angular/common';
|
|
4
|
-
import { CommonEngine } from '
|
|
4
|
+
import { CommonEngine } from '<%= commonEngineEntryPoint %>';
|
|
5
5
|
import * as express from 'express';
|
|
6
6
|
import * as cors from 'cors';
|
|
7
7
|
import { existsSync } from 'node:fs';
|
|
@@ -12,11 +12,12 @@ async function updateSsrSetup(tree, { appName, port, standalone, typescriptConfi
|
|
|
12
12
|
const browserBundleOutput = project.targets.build.options.outputPath;
|
|
13
13
|
const serverBundleOutput = project.targets.build.options.outputPath.replace(/\/browser$/, '/server');
|
|
14
14
|
const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
15
|
-
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, '../files/common'
|
|
15
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, '../files/common'), project.root, {
|
|
16
16
|
appName,
|
|
17
17
|
browserBundleOutput,
|
|
18
18
|
serverBundleOutput,
|
|
19
19
|
standalone,
|
|
20
|
+
commonEngineEntryPoint: angularMajorVersion >= 19 ? '@angular/ssr/node' : '@angular/ssr',
|
|
20
21
|
tmpl: '',
|
|
21
22
|
});
|
|
22
23
|
const pathToTemplateFiles = typescriptConfiguration ? 'base-ts' : 'base';
|
|
@@ -165,6 +165,10 @@
|
|
|
165
165
|
"type": "boolean",
|
|
166
166
|
"default": false
|
|
167
167
|
},
|
|
168
|
+
"serverRouting": {
|
|
169
|
+
"description": "Creates a server application using the Server Routing and App Engine APIs (Developer Preview). _Note: this is only supported in Angular versions >= 19.0.0_.",
|
|
170
|
+
"type": "boolean"
|
|
171
|
+
},
|
|
168
172
|
"typescriptConfiguration": {
|
|
169
173
|
"type": "boolean",
|
|
170
174
|
"description": "Whether the module federation configuration and webpack configuration files should use TS.",
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = normalizeOptions;
|
|
4
|
-
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
6
|
+
const validations_1 = require("../../utils/validations");
|
|
6
7
|
async function normalizeOptions(tree, options) {
|
|
7
8
|
options.type ??= 'component';
|
|
8
9
|
const { artifactName: name, directory, fileName, filePath, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
|
|
@@ -13,6 +14,7 @@ async function normalizeOptions(tree, options) {
|
|
|
13
14
|
const { className } = (0, devkit_1.names)(name);
|
|
14
15
|
const { className: suffixClassName } = (0, devkit_1.names)(options.type);
|
|
15
16
|
const symbolName = `${className}${suffixClassName}`;
|
|
17
|
+
(0, validations_1.validateClassName)(symbolName);
|
|
16
18
|
return {
|
|
17
19
|
...options,
|
|
18
20
|
export: options.export ?? true,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = normalizeOptions;
|
|
4
|
-
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
6
|
+
const validations_1 = require("../../utils/validations");
|
|
6
7
|
async function normalizeOptions(tree, options) {
|
|
7
8
|
const { artifactName: name, directory, fileName, filePath, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
|
|
8
9
|
name: options.name,
|
|
@@ -12,6 +13,7 @@ async function normalizeOptions(tree, options) {
|
|
|
12
13
|
const { className } = (0, devkit_1.names)(name);
|
|
13
14
|
const { className: suffixClassName } = (0, devkit_1.names)('directive');
|
|
14
15
|
const symbolName = `${className}${suffixClassName}`;
|
|
16
|
+
(0, validations_1.validateClassName)(symbolName);
|
|
15
17
|
return {
|
|
16
18
|
...options,
|
|
17
19
|
export: options.export ?? true,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = normalizeOptions;
|
|
4
|
-
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
6
|
+
const validations_1 = require("../../utils/validations");
|
|
6
7
|
async function normalizeOptions(tree, options) {
|
|
7
8
|
const { artifactName: name, directory, fileName, filePath, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
|
|
8
9
|
name: options.name,
|
|
@@ -12,6 +13,7 @@ async function normalizeOptions(tree, options) {
|
|
|
12
13
|
const { className } = (0, devkit_1.names)(name);
|
|
13
14
|
const { className: suffixClassName } = (0, devkit_1.names)('pipe');
|
|
14
15
|
const symbolName = `${className}${suffixClassName}`;
|
|
16
|
+
(0, validations_1.validateClassName)(symbolName);
|
|
15
17
|
return {
|
|
16
18
|
...options,
|
|
17
19
|
export: options.export ?? true,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
1
2
|
import type { Node, SourceFile } from 'typescript';
|
|
2
|
-
import { Tree } from 'nx/src/generators/tree';
|
|
3
3
|
export declare function convertScamToStandalone(componentAST: SourceFile, componentFileContents: string, importsArray: string[], providersArray: string[], moduleNodes: Array<Node>, tree: Tree, normalizedComponentPath: string, componentName: string): void;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertScamToStandalone = convertScamToStandalone;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
5
|
const path_1 = require("path");
|
|
5
|
-
const
|
|
6
|
+
const version_utils_1 = require("../../utils/version-utils");
|
|
6
7
|
function convertScamToStandalone(componentAST, componentFileContents, importsArray, providersArray, moduleNodes, tree, normalizedComponentPath, componentName) {
|
|
7
8
|
let newComponentContents = '';
|
|
8
9
|
const COMPONENT_PROPERTY_SELECTOR = 'ClassDeclaration > Decorator > CallExpression:has(Identifier[name=Component]) ObjectLiteralExpression';
|
|
9
10
|
const { tsquery } = require('@phenomnomnominal/tsquery');
|
|
10
11
|
const componentDecoratorMetadataNode = tsquery(componentAST, COMPONENT_PROPERTY_SELECTOR, { visitAllChildren: true })[0];
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
13
|
+
newComponentContents = `${componentFileContents.slice(0, componentDecoratorMetadataNode.getStart() - 1)}({${angularMajorVersion < 19 ? `\nstandalone: true,` : ''}
|
|
13
14
|
imports: [${importsArray.join(',')}],${providersArray.length > 0 ? `providers: [${providersArray.join(',')}],` : ''}${componentFileContents.slice(componentDecoratorMetadataNode.getStart() + 1, moduleNodes[0].getStart() - 1)}`;
|
|
14
15
|
tree.write(normalizedComponentPath, newComponentContents);
|
|
15
16
|
const componentPathParts = (0, path_1.parse)(normalizedComponentPath);
|
|
16
|
-
const pathToComponentSpec = (0,
|
|
17
|
+
const pathToComponentSpec = (0, devkit_1.joinPathFragments)(componentPathParts.dir, '/', `${componentPathParts.name}.spec.ts`);
|
|
17
18
|
if (tree.exists(pathToComponentSpec)) {
|
|
18
19
|
const componentSpecContents = tree.read(pathToComponentSpec, 'utf-8');
|
|
19
20
|
// Only support testbed based tests
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Component } from '@angular/core';
|
|
2
2
|
|
|
3
3
|
@Component({<% if (prefix) { %>
|
|
4
|
-
selector: '<%= prefix %>-<%= appName %>-entry'
|
|
4
|
+
selector: '<%= prefix %>-<%= appName %>-entry',<% if (setStandaloneFalse) { %>
|
|
5
|
+
standalone: false,<% } %>
|
|
5
6
|
template: `<<%= prefix %>-nx-welcome></<%= prefix %>-nx-welcome>`<% } else { %>
|
|
6
7
|
selector: '<%= appName %>-entry',
|
|
7
8
|
template: `<nx-welcome></nx-welcome>`<% } %>
|
package/src/generators/setup-mf/files/standalone-entry-component-files/entry.component.ts__tmpl__
CHANGED
|
@@ -2,8 +2,8 @@ import { Component } from '@angular/core';
|
|
|
2
2
|
import { CommonModule } from '@angular/common';
|
|
3
3
|
import { NxWelcomeComponent } from './nx-welcome.component';
|
|
4
4
|
|
|
5
|
-
@Component({
|
|
6
|
-
standalone: true
|
|
5
|
+
@Component({<% if (setStandaloneTrue) { %>
|
|
6
|
+
standalone: true,<% } %>
|
|
7
7
|
imports: [CommonModule, NxWelcomeComponent],<% if (prefix) { %>
|
|
8
8
|
selector: '<%= prefix %>-<%= appName %>-entry',
|
|
9
9
|
template: `<<%= prefix %>-nx-welcome></<%= prefix %>-nx-welcome>`<% } else { %>
|
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.addRemoteEntry = addRemoteEntry;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const route_utils_1 = require("../../../utils/nx-devkit/route-utils");
|
|
6
|
+
const version_utils_1 = require("../../utils/version-utils");
|
|
6
7
|
function addRemoteEntry(tree, { appName, routing, prefix, standalone }, appRoot) {
|
|
8
|
+
const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
7
9
|
(0, devkit_1.generateFiles)(tree, standalone
|
|
8
10
|
? (0, devkit_1.joinPathFragments)(__dirname, '../files/standalone-entry-component-files')
|
|
9
11
|
: (0, devkit_1.joinPathFragments)(__dirname, '../files/entry-module-files'), `${appRoot}/src/app/remote-entry`, {
|
|
@@ -11,6 +13,9 @@ function addRemoteEntry(tree, { appName, routing, prefix, standalone }, appRoot)
|
|
|
11
13
|
appName,
|
|
12
14
|
routing,
|
|
13
15
|
prefix,
|
|
16
|
+
// Angular v19 or higher defaults to true, while v18 or lower defaults to false
|
|
17
|
+
setStandaloneFalse: angularMajorVersion >= 19,
|
|
18
|
+
setStandaloneTrue: angularMajorVersion < 19,
|
|
14
19
|
});
|
|
15
20
|
if (standalone && routing) {
|
|
16
21
|
(0, route_utils_1.addRoute)(tree, (0, devkit_1.joinPathFragments)(appRoot, 'src/app/app.routes.ts'), `{path: '', loadChildren: () => import('./remote-entry/entry.routes').then(m => m.remoteRoutes)}`);
|
|
@@ -9,7 +9,7 @@ import <% if (standalone) { %>bootstrap<% } else { %><%= rootModuleClassName %><
|
|
|
9
9
|
export function app(): express.Express {
|
|
10
10
|
const server = express();
|
|
11
11
|
const serverDistFolder = dirname(fileURLToPath(import.meta.url));
|
|
12
|
-
const browserDistFolder = resolve(serverDistFolder, '../<%=
|
|
12
|
+
const browserDistFolder = resolve(serverDistFolder, '../<%= browserDistDirectory %>');
|
|
13
13
|
const indexHtml = join(serverDistFolder, 'index.server.html');
|
|
14
14
|
|
|
15
15
|
const commonEngine = new CommonEngine();
|
|
@@ -10,7 +10,7 @@ import <% if (standalone) { %>bootstrap<% } else { %><%= rootModuleClassName %><
|
|
|
10
10
|
// The Express app is exported so that it can be used by serverless Functions.
|
|
11
11
|
export function app(): express.Express {
|
|
12
12
|
const server = express();
|
|
13
|
-
const distFolder = join(process.cwd(), '<%=
|
|
13
|
+
const distFolder = join(process.cwd(), '<%= browserDistDirectory %>');
|
|
14
14
|
const indexHtml = existsSync(join(distFolder, 'index.original.html'))
|
|
15
15
|
? join(distFolder, 'index.original.html')
|
|
16
16
|
: join(distFolder, 'index.html');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { <%= rootModuleClassName %> as default } from './app/<%= rootModuleFileName.slice(0, -3) %>';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { ServerModule } from '@angular/platform-server';<% if(serverRouting) { %>
|
|
3
|
+
import { provideServerRoutesConfig } from '@angular/ssr';<% } %>
|
|
4
|
+
import { AppComponent } from './app.component';
|
|
5
|
+
import { AppModule } from './app.module';<% if(serverRouting) { %>
|
|
6
|
+
import { serverRoutes } from './app.routes.server';<% } %>
|
|
7
|
+
|
|
8
|
+
@NgModule({
|
|
9
|
+
imports: [AppModule, ServerModule],<% if(serverRouting) { %>
|
|
10
|
+
providers: [provideServerRoutesConfig(serverRoutes)],<% } %>
|
|
11
|
+
bootstrap: [AppComponent],
|
|
12
|
+
})
|
|
13
|
+
export class <%= rootModuleClassName %> {}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AngularNodeAppEngine,
|
|
3
|
+
createNodeRequestHandler,
|
|
4
|
+
isMainModule,
|
|
5
|
+
writeResponseToNodeResponse,
|
|
6
|
+
} from '@angular/ssr/node';
|
|
7
|
+
import express from 'express';
|
|
8
|
+
import { dirname, resolve } from 'node:path';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
|
|
11
|
+
const serverDistFolder = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const browserDistFolder = resolve(serverDistFolder, '../<%= browserDistDirectory %>');
|
|
13
|
+
|
|
14
|
+
const app = express();
|
|
15
|
+
const angularApp = new AngularNodeAppEngine();
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Example Express Rest API endpoints can be defined here.
|
|
19
|
+
* Uncomment and define endpoints as necessary.
|
|
20
|
+
*
|
|
21
|
+
* Example:
|
|
22
|
+
* ```ts
|
|
23
|
+
* app.get('/api/**', (req, res) => {
|
|
24
|
+
* // Handle API request
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Serve static files from /<%= browserDistDirectory %>
|
|
31
|
+
*/
|
|
32
|
+
app.use(
|
|
33
|
+
express.static(browserDistFolder, {
|
|
34
|
+
maxAge: '1y',
|
|
35
|
+
index: false,
|
|
36
|
+
redirect: false,
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Handle all other requests by rendering the Angular application.
|
|
42
|
+
*/
|
|
43
|
+
app.use('/**', (req, res, next) => {
|
|
44
|
+
angularApp
|
|
45
|
+
.handle(req)
|
|
46
|
+
.then((response) =>
|
|
47
|
+
response ? writeResponseToNodeResponse(response, res) : next()
|
|
48
|
+
)
|
|
49
|
+
.catch(next);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Start the server if this module is the main entry point.
|
|
54
|
+
* The server listens on the port defined by the `PORT` environment variable, or defaults to <%= serverPort %>.
|
|
55
|
+
*/
|
|
56
|
+
if (isMainModule(import.meta.url)) {
|
|
57
|
+
const port = process.env['PORT'] || <%= serverPort %>;
|
|
58
|
+
app.listen(port, () => {
|
|
59
|
+
console.log(`Node Express server listening on http://localhost:${port}`);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The request handler used by the Angular CLI (dev-server and during build).
|
|
65
|
+
*/
|
|
66
|
+
export const reqHandler = createNodeRequestHandler(app);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { bootstrapApplication } from '@angular/platform-browser';
|
|
2
|
+
import { AppComponent } from './app/app.component';
|
|
3
|
+
import { config } from './app/app.config.server';
|
|
4
|
+
|
|
5
|
+
const bootstrap = () => bootstrapApplication(AppComponent, config);
|
|
6
|
+
|
|
7
|
+
export default bootstrap;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
|
|
2
|
+
import { provideServerRendering } from '@angular/platform-server';<% if(serverRouting) { %>
|
|
3
|
+
import { provideServerRoutesConfig } from '@angular/ssr';<% } %>
|
|
4
|
+
import { appConfig } from './app.config';<% if(serverRouting) { %>
|
|
5
|
+
import { serverRoutes } from './app.routes.server';<% } %>
|
|
6
|
+
|
|
7
|
+
const serverConfig: ApplicationConfig = {
|
|
8
|
+
providers: [
|
|
9
|
+
provideServerRendering()<% if(serverRouting) { %>,
|
|
10
|
+
provideServerRoutesConfig(serverRoutes)<% } %>
|
|
11
|
+
]
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const config = mergeApplicationConfig(appConfig, serverConfig);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { APP_BASE_HREF } from '@angular/common';
|
|
2
|
+
import { CommonEngine, isMainModule } from '@angular/ssr/node';
|
|
3
|
+
import express from 'express';
|
|
4
|
+
import { dirname, join, resolve } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import <% if (standalone) { %>bootstrap<% } else { %><%= rootModuleClassName %><% } %> from './<%= main.slice(0, -3) %>';
|
|
7
|
+
|
|
8
|
+
const serverDistFolder = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const browserDistFolder = resolve(serverDistFolder, '../<%= browserDistDirectory %>');
|
|
10
|
+
const indexHtml = join(serverDistFolder, 'index.server.html');
|
|
11
|
+
|
|
12
|
+
const app = express();
|
|
13
|
+
const commonEngine = new CommonEngine();
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Example Express Rest API endpoints can be defined here.
|
|
17
|
+
* Uncomment and define endpoints as necessary.
|
|
18
|
+
*
|
|
19
|
+
* Example:
|
|
20
|
+
* ```ts
|
|
21
|
+
* app.get('/api/**', (req, res) => {
|
|
22
|
+
* // Handle API request
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Serve static files from /<%= browserDistDirectory %>
|
|
29
|
+
*/
|
|
30
|
+
app.get(
|
|
31
|
+
'**',
|
|
32
|
+
express.static(browserDistFolder, {
|
|
33
|
+
maxAge: '1y',
|
|
34
|
+
index: 'index.html'
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Handle all other requests by rendering the Angular application.
|
|
40
|
+
*/
|
|
41
|
+
app.get('**', (req, res, next) => {
|
|
42
|
+
const { protocol, originalUrl, baseUrl, headers } = req;
|
|
43
|
+
|
|
44
|
+
commonEngine
|
|
45
|
+
.render({
|
|
46
|
+
bootstrap<% if (!standalone) { %>: <%= rootModuleClassName %><% } %>,
|
|
47
|
+
documentFilePath: indexHtml,
|
|
48
|
+
url: `${protocol}://${headers.host}${originalUrl}`,
|
|
49
|
+
publicPath: browserDistFolder,
|
|
50
|
+
providers: [{ provide: APP_BASE_HREF, useValue: baseUrl }],
|
|
51
|
+
})
|
|
52
|
+
.then((html) => res.send(html))
|
|
53
|
+
.catch((err) => next(err));
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Start the server if this module is the main entry point.
|
|
58
|
+
* The server listens on the port defined by the `PORT` environment variable, or defaults to 4000.
|
|
59
|
+
*/
|
|
60
|
+
if (isMainModule(import.meta.url)) {
|
|
61
|
+
const port = process.env['PORT'] || <%= serverPort %>;
|
|
62
|
+
app.listen(port, () => {
|
|
63
|
+
console.log(`Node Express server listening on http://localhost:${port}`);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { <%= rootModuleClassName %> as default } from './app/<%= rootModuleFileName.slice(0, -3) %>';
|
package/src/generators/setup-ssr/files/v19+/server-builder/ngmodule-src/app/__rootModuleFileName__
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { ServerModule } from '@angular/platform-server';
|
|
3
|
+
|
|
4
|
+
import { AppModule } from './app.module';
|
|
5
|
+
import { AppComponent } from './app.component';
|
|
6
|
+
|
|
7
|
+
@NgModule({
|
|
8
|
+
imports: [
|
|
9
|
+
AppModule,
|
|
10
|
+
ServerModule,
|
|
11
|
+
],
|
|
12
|
+
bootstrap: [AppComponent],
|
|
13
|
+
})
|
|
14
|
+
export class <%= rootModuleClassName %> {}
|