@nx/angular 20.2.0-canary.20241129-2cb58b9 → 20.2.0-canary.20241203-6b87005
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 +151 -1
- package/package.json +8 -15
- 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/module-federation-dev-server.impl.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 +8 -12
- package/src/executors/module-federation-ssr-dev-server/schema.d.ts +2 -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/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/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/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
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type Tree } from '@nx/devkit';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function setServerTsConfigOptionsForApplicationBuilder(tree: Tree, options:
|
|
4
|
-
export declare function generateTsConfigServerJsonForBrowserBuilder(tree: Tree, options:
|
|
2
|
+
import type { NormalizedGeneratorOptions } from '../schema';
|
|
3
|
+
export declare function setServerTsConfigOptionsForApplicationBuilder(tree: Tree, options: NormalizedGeneratorOptions): void;
|
|
4
|
+
export declare function generateTsConfigServerJsonForBrowserBuilder(tree: Tree, options: NormalizedGeneratorOptions): void;
|
|
@@ -4,13 +4,20 @@ exports.setServerTsConfigOptionsForApplicationBuilder = setServerTsConfigOptions
|
|
|
4
4
|
exports.generateTsConfigServerJsonForBrowserBuilder = generateTsConfigServerJsonForBrowserBuilder;
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const path_1 = require("path");
|
|
7
|
+
const version_utils_1 = require("../../utils/version-utils");
|
|
7
8
|
function setServerTsConfigOptionsForApplicationBuilder(tree, options) {
|
|
8
9
|
const { targets } = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
9
10
|
const tsConfigPath = targets.build.options.tsConfig;
|
|
10
11
|
(0, devkit_1.updateJson)(tree, tsConfigPath, (json) => {
|
|
12
|
+
const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
11
13
|
const files = new Set(json.files ?? []);
|
|
12
14
|
files.add((0, devkit_1.joinPathFragments)('src', options.main));
|
|
13
|
-
|
|
15
|
+
if (angularMajorVersion >= 19) {
|
|
16
|
+
files.add((0, devkit_1.joinPathFragments)('src', options.serverFileName));
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
files.add((0, devkit_1.joinPathFragments)(options.serverFileName));
|
|
20
|
+
}
|
|
14
21
|
json.files = Array.from(files);
|
|
15
22
|
json.compilerOptions ??= {};
|
|
16
23
|
const types = new Set(json.compilerOptions.types ?? []);
|
|
@@ -20,9 +27,23 @@ function setServerTsConfigOptionsForApplicationBuilder(tree, options) {
|
|
|
20
27
|
});
|
|
21
28
|
}
|
|
22
29
|
function generateTsConfigServerJsonForBrowserBuilder(tree, options) {
|
|
23
|
-
const
|
|
24
|
-
|
|
30
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
31
|
+
const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
32
|
+
const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
33
|
+
const hasLocalizePackage = !!packageJson.dependencies?.['@angular/localize'] ||
|
|
34
|
+
!!packageJson.devDependencies?.['@angular/localize'];
|
|
35
|
+
const baseFilesPath = (0, path_1.join)(__dirname, '..', 'files');
|
|
36
|
+
let pathToFiles;
|
|
37
|
+
if (angularMajorVersion >= 19) {
|
|
38
|
+
pathToFiles = (0, path_1.join)(baseFilesPath, 'v19+', 'server-builder', 'root');
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
pathToFiles = (0, path_1.join)(baseFilesPath, 'pre-v19', 'root');
|
|
42
|
+
}
|
|
43
|
+
(0, devkit_1.generateFiles)(tree, pathToFiles, project.root, {
|
|
25
44
|
...options,
|
|
45
|
+
rootOffset: (0, devkit_1.offsetFromRoot)(project.root),
|
|
46
|
+
hasLocalizePackage,
|
|
26
47
|
tpl: '',
|
|
27
48
|
});
|
|
28
49
|
}
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { Schema } from '../schema';
|
|
3
|
-
export declare function normalizeOptions(tree: Tree, options: Schema):
|
|
4
|
-
project: string;
|
|
5
|
-
appId: string;
|
|
6
|
-
main: string;
|
|
7
|
-
serverFileName: string;
|
|
8
|
-
serverPort: number;
|
|
9
|
-
rootModuleFileName: string;
|
|
10
|
-
rootModuleClassName: string;
|
|
11
|
-
skipFormat: boolean;
|
|
12
|
-
standalone: boolean;
|
|
13
|
-
hydration: boolean;
|
|
14
|
-
};
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
import type { NormalizedGeneratorOptions, Schema } from '../schema';
|
|
3
|
+
export declare function normalizeOptions(tree: Tree, options: Schema): Promise<NormalizedGeneratorOptions>;
|
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = normalizeOptions;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const prompt_1 = require("@nx/devkit/src/generators/prompt");
|
|
4
6
|
const ast_utils_1 = require("../../../utils/nx-devkit/ast-utils");
|
|
5
7
|
const version_utils_1 = require("../../utils/version-utils");
|
|
6
|
-
function normalizeOptions(tree, options) {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
async function normalizeOptions(tree, options) {
|
|
9
|
+
const { targets } = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
10
|
+
const isUsingApplicationBuilder = targets.build.executor === '@angular-devkit/build-angular:application' ||
|
|
11
|
+
targets.build.executor === '@angular/build:application' ||
|
|
12
|
+
targets.build.executor === '@nx/angular:application';
|
|
13
|
+
if (options.serverRouting === undefined && isUsingApplicationBuilder) {
|
|
10
14
|
const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
11
|
-
|
|
15
|
+
if (angularMajorVersion >= 19) {
|
|
16
|
+
options.serverRouting = await (0, prompt_1.promptWhenInteractive)({
|
|
17
|
+
type: 'confirm',
|
|
18
|
+
name: 'serverRouting',
|
|
19
|
+
message: 'Would you like to use the Server Routing and App Engine APIs (Developer Preview) for this server application?',
|
|
20
|
+
initial: false,
|
|
21
|
+
}, { serverRouting: false }).then(({ serverRouting }) => serverRouting);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
options.serverRouting = false;
|
|
25
|
+
}
|
|
12
26
|
}
|
|
27
|
+
const isStandaloneApp = (0, ast_utils_1.isNgStandaloneApp)(tree, options.project);
|
|
13
28
|
return {
|
|
14
29
|
project: options.project,
|
|
15
30
|
appId: options.appId ?? 'serverApp',
|
|
@@ -20,6 +35,8 @@ function normalizeOptions(tree, options) {
|
|
|
20
35
|
rootModuleClassName: options.rootModuleClassName ?? 'AppServerModule',
|
|
21
36
|
skipFormat: options.skipFormat ?? false,
|
|
22
37
|
standalone: options.standalone ?? isStandaloneApp,
|
|
23
|
-
hydration,
|
|
38
|
+
hydration: options.hydration ?? true,
|
|
39
|
+
serverRouting: options.serverRouting,
|
|
40
|
+
isUsingApplicationBuilder,
|
|
24
41
|
};
|
|
25
42
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type Tree } from '@nx/devkit';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function setRouterInitialNavigation(tree: Tree, options:
|
|
2
|
+
import type { NormalizedGeneratorOptions } from '../schema';
|
|
3
|
+
export declare function setRouterInitialNavigation(tree: Tree, options: NormalizedGeneratorOptions): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Tree } from '@nx/devkit';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function updateProjectConfigForApplicationBuilder(tree: Tree, options:
|
|
4
|
-
export declare function updateProjectConfigForBrowserBuilder(tree: Tree,
|
|
2
|
+
import type { NormalizedGeneratorOptions } from '../schema';
|
|
3
|
+
export declare function updateProjectConfigForApplicationBuilder(tree: Tree, options: NormalizedGeneratorOptions): void;
|
|
4
|
+
export declare function updateProjectConfigForBrowserBuilder(tree: Tree, options: NormalizedGeneratorOptions): void;
|
|
@@ -23,17 +23,32 @@ function updateProjectConfigForApplicationBuilder(tree, options) {
|
|
|
23
23
|
outputPath = outputPath.base;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
27
|
+
const sourceRoot = project.sourceRoot ?? (0, devkit_1.joinPathFragments)(project.root, 'src');
|
|
26
28
|
buildTarget.options ??= {};
|
|
27
29
|
buildTarget.options.outputPath = outputPath;
|
|
28
|
-
buildTarget.options.server = (0, devkit_1.joinPathFragments)(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
buildTarget.options.server = (0, devkit_1.joinPathFragments)(sourceRoot, options.main);
|
|
31
|
+
if (angularMajorVersion >= 19) {
|
|
32
|
+
buildTarget.options.ssr = {
|
|
33
|
+
entry: (0, devkit_1.joinPathFragments)(sourceRoot, options.serverFileName),
|
|
34
|
+
};
|
|
35
|
+
if (options.serverRouting) {
|
|
36
|
+
buildTarget.options.outputMode = 'server';
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
buildTarget.options.prerender = true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
buildTarget.options.prerender = true;
|
|
44
|
+
buildTarget.options.ssr = {
|
|
45
|
+
entry: (0, devkit_1.joinPathFragments)(project.root, options.serverFileName),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
33
48
|
(0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
|
|
34
49
|
}
|
|
35
|
-
function updateProjectConfigForBrowserBuilder(tree,
|
|
36
|
-
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree,
|
|
50
|
+
function updateProjectConfigForBrowserBuilder(tree, options) {
|
|
51
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
37
52
|
const buildTarget = projectConfig.targets.build;
|
|
38
53
|
const baseOutputPath = buildTarget.options.outputPath;
|
|
39
54
|
buildTarget.options.outputPath = (0, devkit_1.joinPathFragments)(baseOutputPath, 'browser');
|
|
@@ -44,6 +59,8 @@ function updateProjectConfigForBrowserBuilder(tree, schema) {
|
|
|
44
59
|
configurations[key] = getServerOptions(options);
|
|
45
60
|
}
|
|
46
61
|
}
|
|
62
|
+
const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
63
|
+
const sourceRoot = projectConfig.sourceRoot ?? (0, devkit_1.joinPathFragments)(projectConfig.root, 'src');
|
|
47
64
|
projectConfig.targets.server = {
|
|
48
65
|
dependsOn: ['build'],
|
|
49
66
|
executor: buildTarget.executor.startsWith('@angular-devkit/build-angular:')
|
|
@@ -51,50 +68,45 @@ function updateProjectConfigForBrowserBuilder(tree, schema) {
|
|
|
51
68
|
: '@nx/angular:webpack-server',
|
|
52
69
|
options: {
|
|
53
70
|
outputPath: (0, devkit_1.joinPathFragments)(baseOutputPath, 'server'),
|
|
54
|
-
main: (0, devkit_1.joinPathFragments)(projectConfig.root,
|
|
71
|
+
main: (0, devkit_1.joinPathFragments)(angularMajorVersion >= 19 ? sourceRoot : projectConfig.root, options.serverFileName),
|
|
55
72
|
tsConfig: (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.server.json'),
|
|
56
73
|
...(buildTarget.options ? getServerOptions(buildTarget.options) : {}),
|
|
57
74
|
},
|
|
58
75
|
configurations,
|
|
59
76
|
defaultConfiguration: 'production',
|
|
60
77
|
};
|
|
61
|
-
const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
62
78
|
projectConfig.targets['serve-ssr'] = {
|
|
63
|
-
executor:
|
|
64
|
-
? '@angular-devkit/build-angular:ssr-dev-server'
|
|
65
|
-
: '@nguniversal/builders:ssr-dev-server',
|
|
79
|
+
executor: '@angular-devkit/build-angular:ssr-dev-server',
|
|
66
80
|
configurations: {
|
|
67
81
|
development: {
|
|
68
|
-
browserTarget: `${
|
|
69
|
-
serverTarget: `${
|
|
82
|
+
browserTarget: `${options.project}:build:development`,
|
|
83
|
+
serverTarget: `${options.project}:server:development`,
|
|
70
84
|
},
|
|
71
85
|
production: {
|
|
72
|
-
browserTarget: `${
|
|
73
|
-
serverTarget: `${
|
|
86
|
+
browserTarget: `${options.project}:build:production`,
|
|
87
|
+
serverTarget: `${options.project}:server:production`,
|
|
74
88
|
},
|
|
75
89
|
},
|
|
76
90
|
defaultConfiguration: 'development',
|
|
77
91
|
};
|
|
78
92
|
projectConfig.targets.prerender = {
|
|
79
|
-
executor:
|
|
80
|
-
? '@angular-devkit/build-angular:prerender'
|
|
81
|
-
: '@nguniversal/builders:prerender',
|
|
93
|
+
executor: '@angular-devkit/build-angular:prerender',
|
|
82
94
|
options: {
|
|
83
95
|
routes: ['/'],
|
|
84
96
|
},
|
|
85
97
|
configurations: {
|
|
86
98
|
development: {
|
|
87
|
-
browserTarget: `${
|
|
88
|
-
serverTarget: `${
|
|
99
|
+
browserTarget: `${options.project}:build:development`,
|
|
100
|
+
serverTarget: `${options.project}:server:development`,
|
|
89
101
|
},
|
|
90
102
|
production: {
|
|
91
|
-
browserTarget: `${
|
|
92
|
-
serverTarget: `${
|
|
103
|
+
browserTarget: `${options.project}:build:production`,
|
|
104
|
+
serverTarget: `${options.project}:server:production`,
|
|
93
105
|
},
|
|
94
106
|
},
|
|
95
107
|
defaultConfiguration: 'production',
|
|
96
108
|
};
|
|
97
|
-
(0, devkit_1.updateProjectConfiguration)(tree,
|
|
109
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.project, projectConfig);
|
|
98
110
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
99
111
|
if (nxJson.tasksRunnerOptions?.default?.options?.cacheableOperations &&
|
|
100
112
|
!nxJson.tasksRunnerOptions.default.options.cacheableOperations.includes('server')) {
|
|
@@ -3,9 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.validateOptions = validateOptions;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const validations_1 = require("../../utils/validations");
|
|
6
|
+
const version_utils_1 = require("../../utils/version-utils");
|
|
6
7
|
function validateOptions(tree, options) {
|
|
7
8
|
validateProject(tree, options.project);
|
|
8
9
|
validateBuildTarget(tree, options.project);
|
|
10
|
+
const { major: angularMajorVersion, version: angularVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
11
|
+
if (angularMajorVersion < 19 && options.serverRouting) {
|
|
12
|
+
throw new Error(`The "serverRouting" option is only supported in Angular versions >= 19.0.0. You are using Angular ${angularVersion}.`);
|
|
13
|
+
}
|
|
9
14
|
}
|
|
10
15
|
function validateProject(tree, project) {
|
|
11
16
|
(0, validations_1.validateProject)(tree, project);
|
|
@@ -8,6 +8,11 @@ export interface Schema {
|
|
|
8
8
|
rootModuleClassName?: string;
|
|
9
9
|
standalone?: boolean;
|
|
10
10
|
hydration?: boolean;
|
|
11
|
+
serverRouting?: boolean;
|
|
11
12
|
skipFormat?: boolean;
|
|
12
13
|
skipPackageJson?: boolean;
|
|
13
14
|
}
|
|
15
|
+
|
|
16
|
+
export interface NormalizedGeneratorOptions extends Schema {
|
|
17
|
+
isUsingApplicationBuilder: boolean;
|
|
18
|
+
}
|
|
@@ -16,13 +16,6 @@
|
|
|
16
16
|
"x-prompt": "What app would you like to generate an Angular Universal configuration for?",
|
|
17
17
|
"x-dropdown": "projects"
|
|
18
18
|
},
|
|
19
|
-
"appId": {
|
|
20
|
-
"type": "string",
|
|
21
|
-
"format": "html-selector",
|
|
22
|
-
"description": "The `appId` to use with `withServerTransition`.",
|
|
23
|
-
"default": "serverApp",
|
|
24
|
-
"x-deprecated": "This is deprecated and ignored since Angular 16 and not supported since Angular 17."
|
|
25
|
-
},
|
|
26
19
|
"main": {
|
|
27
20
|
"type": "string",
|
|
28
21
|
"format": "path",
|
|
@@ -56,7 +49,12 @@
|
|
|
56
49
|
},
|
|
57
50
|
"hydration": {
|
|
58
51
|
"type": "boolean",
|
|
59
|
-
"description": "Set up Hydration for the SSR application.
|
|
52
|
+
"description": "Set up Hydration for the SSR application.",
|
|
53
|
+
"default": true
|
|
54
|
+
},
|
|
55
|
+
"serverRouting": {
|
|
56
|
+
"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_.",
|
|
57
|
+
"type": "boolean"
|
|
60
58
|
},
|
|
61
59
|
"skipFormat": {
|
|
62
60
|
"type": "boolean",
|
|
@@ -2,26 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setupSsr = setupSsr;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const version_utils_1 = require("../utils/version-utils");
|
|
6
5
|
const lib_1 = require("./lib");
|
|
7
6
|
async function setupSsr(tree, schema) {
|
|
8
7
|
(0, lib_1.validateOptions)(tree, schema);
|
|
9
|
-
const options = (0, lib_1.normalizeOptions)(tree, schema);
|
|
10
|
-
const { targets } = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
11
|
-
const isUsingApplicationBuilder = targets.build.executor === '@angular-devkit/build-angular:application' ||
|
|
12
|
-
targets.build.executor === '@nx/angular:application';
|
|
8
|
+
const options = await (0, lib_1.normalizeOptions)(tree, schema);
|
|
13
9
|
if (!schema.skipPackageJson) {
|
|
14
|
-
(0, lib_1.addDependencies)(tree, isUsingApplicationBuilder);
|
|
10
|
+
(0, lib_1.addDependencies)(tree, options.isUsingApplicationBuilder);
|
|
15
11
|
}
|
|
16
|
-
(0, lib_1.generateSSRFiles)(tree, options
|
|
12
|
+
(0, lib_1.generateSSRFiles)(tree, options);
|
|
17
13
|
if (options.hydration) {
|
|
18
14
|
(0, lib_1.addHydration)(tree, options);
|
|
19
15
|
}
|
|
20
|
-
|
|
21
|
-
if (angularMajorVersion < 17 || !options.hydration) {
|
|
16
|
+
if (!options.hydration) {
|
|
22
17
|
(0, lib_1.setRouterInitialNavigation)(tree, options);
|
|
23
18
|
}
|
|
24
|
-
if (isUsingApplicationBuilder) {
|
|
19
|
+
if (options.isUsingApplicationBuilder) {
|
|
25
20
|
(0, lib_1.updateProjectConfigForApplicationBuilder)(tree, options);
|
|
26
21
|
(0, lib_1.setServerTsConfigOptionsForApplicationBuilder)(tree, options);
|
|
27
22
|
}
|
|
@@ -29,7 +24,7 @@ async function setupSsr(tree, schema) {
|
|
|
29
24
|
(0, lib_1.updateProjectConfigForBrowserBuilder)(tree, options);
|
|
30
25
|
(0, lib_1.generateTsConfigServerJsonForBrowserBuilder)(tree, options);
|
|
31
26
|
}
|
|
32
|
-
(0, lib_1.addServerFile)(tree, options
|
|
27
|
+
(0, lib_1.addServerFile)(tree, options);
|
|
33
28
|
if (!options.skipFormat) {
|
|
34
29
|
await (0, devkit_1.formatFiles)(tree);
|
|
35
30
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './add-tailwind-config-path-to-project';
|
|
2
1
|
export * from './add-tailwind-config';
|
|
3
2
|
export * from './add-tailwind-required-packages';
|
|
4
3
|
export * from './detect-tailwind-installed-version';
|
|
5
4
|
export * from './normalize-options';
|
|
6
5
|
export * from './update-application-styles';
|
|
6
|
+
export * from './validate-build-target';
|
|
@@ -1,9 +1,9 @@
|
|
|
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-tailwind-config-path-to-project"), exports);
|
|
5
4
|
tslib_1.__exportStar(require("./add-tailwind-config"), exports);
|
|
6
5
|
tslib_1.__exportStar(require("./add-tailwind-required-packages"), exports);
|
|
7
6
|
tslib_1.__exportStar(require("./detect-tailwind-installed-version"), exports);
|
|
8
7
|
tslib_1.__exportStar(require("./normalize-options"), exports);
|
|
9
8
|
tslib_1.__exportStar(require("./update-application-styles"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./validate-build-target"), exports);
|
|
@@ -34,7 +34,7 @@ function findStylesEntryPoint(tree, options, project) {
|
|
|
34
34
|
return stylesEntryPoint;
|
|
35
35
|
}
|
|
36
36
|
// then check for the specified styles in the build configuration if it exists
|
|
37
|
-
const styles = project.targets?.[options.buildTarget]
|
|
37
|
+
const styles = project.targets?.[options.buildTarget]?.options?.styles;
|
|
38
38
|
if (!styles) {
|
|
39
39
|
return undefined;
|
|
40
40
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.validateBuildTarget = validateBuildTarget;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
function
|
|
5
|
+
function validateBuildTarget(options, project) {
|
|
6
6
|
const buildTarget = project.targets?.[options.buildTarget];
|
|
7
7
|
if (!buildTarget) {
|
|
8
8
|
throw new Error((0, devkit_1.stripIndents) `The target "${options.buildTarget}" was not found for project "${options.project}".
|
|
@@ -10,25 +10,14 @@ function addTailwindConfigPathToProject(tree, options, project) {
|
|
|
10
10
|
If the project is not a buildable or publishable library, you don't need to setup TailwindCSS for it.`);
|
|
11
11
|
}
|
|
12
12
|
const supportedLibraryExecutors = [
|
|
13
|
+
'@angular-devkit/build-angular:ng-packagr',
|
|
13
14
|
'@nx/angular:ng-packagr-lite',
|
|
14
15
|
'@nx/angular:package',
|
|
15
|
-
'@nrwl/angular:ng-packagr-lite',
|
|
16
|
-
'@nrwl/angular:package',
|
|
17
16
|
];
|
|
18
|
-
if (!supportedLibraryExecutors.includes(buildTarget.executor)) {
|
|
17
|
+
if (!supportedLibraryExecutors.includes(project.targets[options.buildTarget].executor)) {
|
|
19
18
|
throw new Error((0, devkit_1.stripIndents) `The build target for project "${options.project}" is using an unsupported executor "${buildTarget.executor}".
|
|
20
19
|
Supported executors are ${supportedLibraryExecutors
|
|
21
20
|
.map((e) => `"${e}"`)
|
|
22
21
|
.join(', ')}.`);
|
|
23
22
|
}
|
|
24
|
-
if (buildTarget.options?.tailwindConfig &&
|
|
25
|
-
tree.exists(buildTarget.options.tailwindConfig)) {
|
|
26
|
-
throw new Error((0, devkit_1.stripIndents) `The "${buildTarget.options.tailwindConfig}" file is already configured for the project "${options.project}". Are you sure this is the right project to set up Tailwind?
|
|
27
|
-
If you are sure, you can remove the configuration and re-run the generator.`);
|
|
28
|
-
}
|
|
29
|
-
buildTarget.options = {
|
|
30
|
-
...buildTarget.options,
|
|
31
|
-
tailwindConfig: (0, devkit_1.joinPathFragments)(project.root, 'tailwind.config.js'),
|
|
32
|
-
};
|
|
33
|
-
(0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
|
|
34
23
|
}
|
|
@@ -6,6 +6,9 @@ const lib_1 = require("./lib");
|
|
|
6
6
|
async function setupTailwindGenerator(tree, rawOptions) {
|
|
7
7
|
const options = (0, lib_1.normalizeOptions)(rawOptions);
|
|
8
8
|
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
9
|
+
if (rawOptions.buildTarget && !project.targets?.[rawOptions.buildTarget]) {
|
|
10
|
+
throw new Error(`The provided target "${options.buildTarget}" was not found for project "${options.project}". Please provide a valid build target.`);
|
|
11
|
+
}
|
|
9
12
|
const tailwindInstalledVersion = (0, lib_1.detectTailwindInstalledVersion)(tree);
|
|
10
13
|
let installTask = () => { };
|
|
11
14
|
if (!options.skipPackageJson) {
|
|
@@ -18,7 +21,7 @@ async function setupTailwindGenerator(tree, rawOptions) {
|
|
|
18
21
|
(0, lib_1.updateApplicationStyles)(tree, options, project);
|
|
19
22
|
}
|
|
20
23
|
else if (project.projectType === 'library') {
|
|
21
|
-
(0, lib_1.
|
|
24
|
+
(0, lib_1.validateBuildTarget)(options, project);
|
|
22
25
|
}
|
|
23
26
|
if (!options.skipFormat) {
|
|
24
27
|
await (0, devkit_1.formatFiles)(tree);
|
|
@@ -6,6 +6,7 @@ const devkit_1 = require("@nx/devkit");
|
|
|
6
6
|
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const ast_utils_1 = require("../../../utils/nx-devkit/ast-utils");
|
|
9
|
+
const version_utils_1 = require("../version-utils");
|
|
9
10
|
const module_info_1 = require("./module-info");
|
|
10
11
|
let tsModule;
|
|
11
12
|
let tsquery;
|
|
@@ -60,8 +61,17 @@ function getStandaloneComponents(tree, filePath) {
|
|
|
60
61
|
}
|
|
61
62
|
const fileContent = tree.read(filePath, 'utf-8');
|
|
62
63
|
const ast = tsquery.ast(fileContent);
|
|
63
|
-
const
|
|
64
|
-
|
|
64
|
+
const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
65
|
+
if (angularMajorVersion < 19) {
|
|
66
|
+
// in angular 18 and below, standalone: false is the default, so only
|
|
67
|
+
// components with standalone: true are considered standalone
|
|
68
|
+
const components = tsquery(ast, 'ClassDeclaration:has(Decorator > CallExpression:has(Identifier[name=Component]) ObjectLiteralExpression PropertyAssignment:has(Identifier[name=standalone]) > TrueKeyword) > Identifier', { visitAllChildren: true });
|
|
69
|
+
return components.map((component) => component.getText());
|
|
70
|
+
}
|
|
71
|
+
// in angular 19 and above, standalone: true is the default, so all components
|
|
72
|
+
// except those with standalone: false are considered standalone
|
|
73
|
+
const standaloneComponentNodes = tsquery(ast, 'ClassDeclaration:has(Decorator > CallExpression:has(Identifier[name=Component]) ObjectLiteralExpression:not(:has(PropertyAssignment:has(Identifier[name=standalone]) > FalseKeyword))) > Identifier', { visitAllChildren: true });
|
|
74
|
+
return standaloneComponentNodes.map((component) => component.getText());
|
|
65
75
|
}
|
|
66
76
|
function getComponentImportPath(componentName, imports) {
|
|
67
77
|
if (!tsModule) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateProject = validateProject;
|
|
4
|
+
exports.validateClassName = validateClassName;
|
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
|
5
6
|
function validateProject(tree, projectName) {
|
|
6
7
|
const projects = (0, devkit_1.getProjects)(tree);
|
|
@@ -8,3 +9,12 @@ function validateProject(tree, projectName) {
|
|
|
8
9
|
throw new Error(`Project "${projectName}" does not exist! Please provide an existing project name.`);
|
|
9
10
|
}
|
|
10
11
|
}
|
|
12
|
+
// The below validation matches that of the Angular CLI:
|
|
13
|
+
// https://github.com/angular/angular-cli/blob/1316930a1cbad8e71a4454743862cfa9253bef4e/packages/schematics/angular/utility/validation.ts#L25
|
|
14
|
+
// See: https://github.com/tc39/proposal-regexp-unicode-property-escapes/blob/fe6d07fad74cd0192d154966baa1e95e7cda78a1/README.md#other-examples
|
|
15
|
+
const ecmaIdentifierNameRegExp = /^(?:[$_\p{ID_Start}])(?:[$_\u200C\u200D\p{ID_Continue}])*$/u;
|
|
16
|
+
function validateClassName(className) {
|
|
17
|
+
if (!ecmaIdentifierNameRegExp.test(className)) {
|
|
18
|
+
throw new Error(`Class name "${className}" is invalid.`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -44,10 +44,10 @@ function getInstalledPackageVersionInfo(tree, pkgName) {
|
|
|
44
44
|
function versions(tree) {
|
|
45
45
|
const majorAngularVersion = getInstalledAngularMajorVersion(tree);
|
|
46
46
|
switch (majorAngularVersion) {
|
|
47
|
-
case 16:
|
|
48
|
-
return backward_compatible_versions_1.backwardCompatibleVersions.angularV16;
|
|
49
47
|
case 17:
|
|
50
48
|
return backward_compatible_versions_1.backwardCompatibleVersions.angularV17;
|
|
49
|
+
case 18:
|
|
50
|
+
return backward_compatible_versions_1.backwardCompatibleVersions.angularV18;
|
|
51
51
|
default:
|
|
52
52
|
return latestVersions;
|
|
53
53
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executorsToAddPolyfillTo = void 0;
|
|
4
|
+
exports.default = default_1;
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const targets_1 = require("../../utils/targets");
|
|
7
|
+
exports.executorsToAddPolyfillTo = [
|
|
8
|
+
'@angular/build:application',
|
|
9
|
+
'@angular-devkit/build-angular:application',
|
|
10
|
+
'@nx/angular:application',
|
|
11
|
+
'@angular-devkit/build-angular:browser-esbuild',
|
|
12
|
+
'@nx/angular:browser-esbuild',
|
|
13
|
+
];
|
|
14
|
+
async function default_1(tree) {
|
|
15
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
16
|
+
for (const [projectName, project] of projects) {
|
|
17
|
+
if (project.projectType !== 'application') {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
let isUpdated = false;
|
|
21
|
+
for (const target of Object.values(project.targets ?? {})) {
|
|
22
|
+
if (!exports.executorsToAddPolyfillTo.includes(target.executor)) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const polyfills = target.options?.['polyfills'];
|
|
26
|
+
if (Array.isArray(polyfills) &&
|
|
27
|
+
polyfills.some((polyfill) => typeof polyfill === 'string' &&
|
|
28
|
+
polyfill.startsWith('@angular/localize'))) {
|
|
29
|
+
// the polyfill is already present, skip
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
// Only add '@angular/localize/init' polyfill if 'localize' option is enabled
|
|
33
|
+
for (const [, options] of (0, targets_1.allTargetOptions)(target)) {
|
|
34
|
+
if (options['localize']) {
|
|
35
|
+
target.options ??= {};
|
|
36
|
+
target.options['polyfills'] ??= [];
|
|
37
|
+
target.options['polyfills'].push('@angular/localize/init');
|
|
38
|
+
isUpdated = true;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (isUpdated) {
|
|
44
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, project);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
48
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.angularCliVersion = void 0;
|
|
4
|
+
exports.default = default_1;
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
exports.angularCliVersion = '~19.0.0';
|
|
7
|
+
async function default_1(tree) {
|
|
8
|
+
let shouldFormat = false;
|
|
9
|
+
(0, devkit_1.updateJson)(tree, 'package.json', (json) => {
|
|
10
|
+
if (json.devDependencies?.['@angular/cli']) {
|
|
11
|
+
json.devDependencies['@angular/cli'] = exports.angularCliVersion;
|
|
12
|
+
shouldFormat = true;
|
|
13
|
+
}
|
|
14
|
+
else if (json.dependencies?.['@angular/cli']) {
|
|
15
|
+
json.dependencies['@angular/cli'] = exports.angularCliVersion;
|
|
16
|
+
shouldFormat = true;
|
|
17
|
+
}
|
|
18
|
+
return json;
|
|
19
|
+
});
|
|
20
|
+
if (shouldFormat) {
|
|
21
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
22
|
+
}
|
|
23
|
+
}
|