@nx/angular 17.1.0-beta.2 → 17.1.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/nx-angular.mjs +1 -1
- package/migrations.json +135 -0
- package/ng-package.json +0 -1
- package/package.json +14 -19
- package/src/builders/module-federation-dev-server/module-federation-dev-server.impl.d.ts +1 -1
- package/src/builders/module-federation-dev-server/module-federation-dev-server.impl.js +112 -60
- package/src/builders/module-federation-dev-server/schema.d.ts +23 -7
- package/src/builders/module-federation-dev-server/schema.json +13 -3
- package/src/builders/module-federation-dev-ssr/module-federation-dev-ssr.impl.d.ts +1 -1
- package/src/builders/module-federation-dev-ssr/module-federation-dev-ssr.impl.js +13 -8
- package/src/builders/webpack-browser/schema.json +7 -7
- package/src/builders/webpack-browser/webpack-browser.impl.js +0 -2
- package/src/builders/webpack-dev-server/lib/normalize-options.d.ts +2 -2
- package/src/builders/webpack-dev-server/lib/normalize-options.js +11 -5
- package/src/builders/webpack-dev-server/schema.d.ts +22 -7
- package/src/builders/webpack-dev-server/schema.json +9 -3
- package/src/builders/webpack-dev-server/webpack-dev-server.impl.js +24 -13
- package/src/builders/webpack-server/schema.d.ts +0 -1
- package/src/builders/webpack-server/schema.json +1 -13
- package/src/builders/webpack-server/validate-options.js +0 -7
- package/src/builders/webpack-server/webpack-server.impl.js +0 -8
- package/src/executors/browser-esbuild/browser-esbuild.impl.js +0 -2
- package/src/executors/browser-esbuild/schema.json +5 -4
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/write-package.transform.js +20 -12
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ngc/compile-source-files.js +10 -1
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/styles/stylesheet-processor.js +0 -13
- package/src/executors/package/ng-packagr-adjustments/ngc/compile-source-files.js +10 -1
- package/src/executors/package/ng-packagr-adjustments/styles/stylesheet-processor.js +0 -13
- package/src/executors/utilities/ng-compiler-cli.d.ts +15 -0
- package/src/executors/utilities/ng-compiler-cli.js +28 -0
- package/src/executors/utilities/typescript.js +1 -1
- package/src/generators/application/application.js +7 -17
- package/src/generators/application/files/base/tsconfig.app.json__tpl__ +1 -1
- package/src/generators/application/files/base/tsconfig.json__tpl__ +3 -2
- package/src/generators/application/files/ng-module/src/app/app.module.ts__tpl__ +1 -1
- package/src/generators/application/files/ng-module/src/app/nx-welcome.component.ts__tpl__ +2 -2
- package/src/generators/application/files/ng-module/src/main.ts__tpl__ +2 -8
- package/src/generators/application/files/standalone-components/src/app/app.config.ts__tpl__ +2 -2
- package/src/generators/application/files/standalone-components/src/app/nx-welcome.component.ts__tpl__ +2 -2
- package/src/generators/application/lib/add-e2e.js +7 -1
- package/src/generators/application/lib/create-files.js +10 -5
- package/src/generators/application/lib/create-project.js +46 -38
- package/src/generators/application/lib/normalize-options.d.ts +1 -1
- package/src/generators/application/lib/normalize-options.js +14 -3
- package/src/generators/application/lib/normalized-schema.d.ts +2 -0
- package/src/generators/application/schema.d.ts +1 -0
- package/src/generators/application/schema.json +13 -6
- package/src/generators/component/component.js +0 -1
- package/src/generators/component/lib/index.d.ts +0 -1
- package/src/generators/component/lib/index.js +0 -1
- package/src/generators/component/lib/normalize-options.js +1 -0
- package/src/generators/component/schema.json +2 -2
- package/src/generators/directive/directive.js +0 -1
- package/src/generators/directive/lib/index.d.ts +0 -1
- package/src/generators/directive/lib/index.js +0 -1
- package/src/generators/directive/lib/normalize-options.js +1 -0
- package/src/generators/directive/schema.json +2 -2
- package/src/generators/federate-module/federate-module.js +1 -0
- package/src/generators/federate-module/lib/add-remote.d.ts +1 -1
- package/src/generators/federate-module/lib/add-remote.js +2 -11
- package/src/generators/federate-module/schema.json +2 -2
- package/src/generators/host/files/common/v17+/src/main.server.ts__tmpl__ +67 -0
- package/src/generators/host/host.js +5 -9
- package/src/generators/host/lib/index.d.ts +1 -1
- package/src/generators/host/lib/index.js +1 -1
- package/src/generators/host/lib/update-ssr-setup.d.ts +3 -0
- package/src/generators/host/lib/{add-ssr.js → update-ssr-setup.js} +8 -14
- package/src/generators/host/schema.json +2 -2
- package/src/generators/library/lib/normalize-options.js +1 -0
- package/src/generators/library/library.js +0 -5
- package/src/generators/library/schema.json +12 -12
- package/src/generators/ng-add/migrators/projects/app.migrator.js +50 -7
- package/src/generators/ngrx/lib/generate-files.js +1 -10
- package/src/generators/ngrx/lib/validate-options.js +0 -23
- package/src/generators/ngrx/schema.json +2 -2
- package/src/generators/ngrx-feature-store/lib/generate-files.js +1 -12
- package/src/generators/ngrx-feature-store/lib/validate-options.js +0 -22
- package/src/generators/ngrx-feature-store/schema.json +2 -2
- package/src/generators/ngrx-root-store/lib/normalize-options.js +1 -1
- package/src/generators/ngrx-root-store/lib/validate-options.js +0 -15
- package/src/generators/ngrx-root-store/schema.json +1 -1
- package/src/generators/pipe/lib/index.d.ts +0 -1
- package/src/generators/pipe/lib/index.js +0 -1
- package/src/generators/pipe/lib/normalize-options.js +1 -0
- package/src/generators/pipe/pipe.js +0 -1
- package/src/generators/pipe/schema.json +2 -2
- package/src/generators/remote/files/common/v17+/src/main.server.ts__tmpl__ +74 -0
- package/src/generators/remote/lib/index.d.ts +1 -1
- package/src/generators/remote/lib/index.js +1 -1
- package/src/generators/remote/lib/{add-ssr.d.ts → update-ssr-setup.d.ts} +1 -1
- package/src/generators/remote/lib/{add-ssr.js → update-ssr-setup.js} +9 -13
- package/src/generators/remote/remote.js +4 -9
- package/src/generators/remote/schema.json +2 -2
- package/src/generators/scam-to-standalone/scam-to-standalone.js +0 -7
- package/src/generators/scam-to-standalone/schema.json +1 -1
- package/src/generators/setup-mf/lib/add-remote-entry.js +2 -11
- package/src/generators/setup-mf/lib/fix-bootstrap.js +3 -12
- package/src/generators/setup-mf/lib/index.d.ts +1 -1
- package/src/generators/setup-mf/lib/index.js +1 -1
- package/src/generators/setup-mf/lib/normalize-options.js +1 -0
- package/src/generators/{component/lib/validate-options.d.ts → setup-mf/lib/update-tsconfig.d.ts} +1 -1
- package/src/generators/setup-mf/lib/update-tsconfig.js +19 -0
- package/src/generators/setup-mf/schema.json +2 -2
- package/src/generators/setup-mf/setup-mf.js +1 -7
- package/src/generators/setup-ssr/files/server/application-builder/__serverFileName__ +54 -0
- package/src/generators/setup-ssr/files/{ngmodule/base → server/server-builder/pre-v17}/__serverFileName__ +3 -4
- package/src/generators/setup-ssr/files/{standalone → server/server-builder/v17+}/__serverFileName__ +25 -16
- package/src/generators/setup-ssr/lib/add-dependencies.d.ts +2 -0
- package/src/generators/setup-ssr/lib/add-dependencies.js +32 -0
- package/src/generators/setup-ssr/lib/generate-files.d.ts +1 -1
- package/src/generators/setup-ssr/lib/generate-files.js +10 -13
- package/src/generators/setup-ssr/lib/generate-server-ts-config.d.ts +4 -0
- package/src/generators/setup-ssr/lib/generate-server-ts-config.js +26 -0
- package/src/generators/setup-ssr/lib/index.d.ts +3 -0
- package/src/generators/setup-ssr/lib/index.js +3 -0
- package/src/generators/setup-ssr/lib/normalize-options.js +7 -1
- package/src/generators/setup-ssr/lib/set-router-initial-navigation.d.ts +3 -0
- package/src/generators/setup-ssr/lib/set-router-initial-navigation.js +93 -0
- package/src/generators/setup-ssr/lib/update-project-config.d.ts +2 -1
- package/src/generators/setup-ssr/lib/update-project-config.js +24 -6
- package/src/generators/setup-ssr/lib/validate-options.js +15 -2
- package/src/generators/setup-ssr/schema.json +3 -3
- package/src/generators/setup-ssr/setup-ssr.js +16 -12
- package/src/generators/utils/create-ts-config.d.ts +1 -0
- package/src/generators/utils/create-ts-config.js +2 -3
- package/src/generators/utils/testing.js +12 -0
- package/src/generators/utils/validations.d.ts +0 -1
- package/src/generators/utils/validations.js +1 -14
- package/src/generators/utils/version-utils.d.ts +2 -2
- package/src/generators/utils/version-utils.js +3 -3
- package/src/migrations/update-17-1-0/browser-target-to-build-target.d.ts +3 -0
- package/src/migrations/update-17-1-0/browser-target-to-build-target.js +50 -0
- package/src/migrations/update-17-1-0/replace-nguniversal-builders.d.ts +2 -0
- package/src/migrations/update-17-1-0/replace-nguniversal-builders.js +75 -0
- package/src/migrations/update-17-1-0/replace-nguniversal-engines.d.ts +2 -0
- package/src/migrations/update-17-1-0/replace-nguniversal-engines.js +185 -0
- package/src/migrations/update-17-1-0/update-angular-cli.d.ts +3 -0
- package/src/migrations/update-17-1-0/update-angular-cli.js +23 -0
- package/src/migrations/update-17-1-0/update-zone-js-deep-import.d.ts +2 -0
- package/src/migrations/update-17-1-0/update-zone-js-deep-import.js +37 -0
- package/src/utils/backward-compatible-versions.d.ts +6 -4
- package/src/utils/backward-compatible-versions.js +18 -18
- package/src/utils/nx-devkit/ast-utils.js +4 -2
- package/src/utils/version-utils.d.ts +3 -3
- package/src/utils/versions.d.ts +6 -7
- package/src/utils/versions.js +7 -8
- package/src/builders/webpack-browser/validate-options.d.ts +0 -2
- package/src/builders/webpack-browser/validate-options.js +0 -40
- package/src/executors/browser-esbuild/lib/validate-options.d.ts +0 -2
- package/src/executors/browser-esbuild/lib/validate-options.js +0 -40
- package/src/generators/application/files/tsconfig.editor.json__tpl__ +0 -5
- package/src/generators/application/files/v14/.browserlistrc__tpl__ +0 -16
- package/src/generators/application/files/v14/src/environments/environment.prod.ts__tpl__ +0 -3
- package/src/generators/application/files/v14/src/environments/environment.ts__tpl__ +0 -16
- package/src/generators/application/files/v14/src/polyfills.ts__tpl__ +0 -53
- package/src/generators/component/lib/validate-options.js +0 -8
- package/src/generators/directive/lib/validate-options.d.ts +0 -3
- package/src/generators/directive/lib/validate-options.js +0 -8
- package/src/generators/host/lib/add-ssr.d.ts +0 -3
- package/src/generators/ngrx/files/no-inject/__directory__/__fileName__.effects.ts__tmpl__ +0 -22
- package/src/generators/ngrx/files/no-inject/__directory__/__fileName__.facade.ts__tmpl__ +0 -27
- package/src/generators/ngrx-feature-store/files/no-inject/__directory__/__fileName__.effects.ts__tmpl__ +0 -22
- package/src/generators/ngrx-feature-store/files/no-inject/__directory__/__fileName__.facade.ts__tmpl__ +0 -27
- package/src/generators/pipe/lib/validate-options.d.ts +0 -3
- package/src/generators/pipe/lib/validate-options.js +0 -8
- package/src/generators/setup-mf/lib/set-tsconfig-target.d.ts +0 -3
- package/src/generators/setup-mf/lib/set-tsconfig-target.js +0 -16
- package/src/generators/setup-ssr/files/ngmodule/v14/src/__main__ +0 -11
- /package/src/generators/host/files/common/{src → pre-v17/src}/main.server.ts__tmpl__ +0 -0
- /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.actions.ts__tmpl__ +0 -0
- /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.effects.spec.ts__tmpl__ +0 -0
- /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.effects.ts__tmpl__ +0 -0
- /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.facade.spec.ts__tmpl__ +0 -0
- /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.facade.ts__tmpl__ +0 -0
- /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.models.ts__tmpl__ +0 -0
- /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.reducer.spec.ts__tmpl__ +0 -0
- /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.reducer.ts__tmpl__ +0 -0
- /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.selectors.spec.ts__tmpl__ +0 -0
- /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.selectors.ts__tmpl__ +0 -0
- /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.actions.ts__tmpl__ +0 -0
- /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.effects.spec.ts__tmpl__ +0 -0
- /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.effects.ts__tmpl__ +0 -0
- /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.facade.spec.ts__tmpl__ +0 -0
- /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.facade.ts__tmpl__ +0 -0
- /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.models.ts__tmpl__ +0 -0
- /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.reducer.spec.ts__tmpl__ +0 -0
- /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.reducer.ts__tmpl__ +0 -0
- /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.selectors.spec.ts__tmpl__ +0 -0
- /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.selectors.ts__tmpl__ +0 -0
- /package/src/generators/remote/files/common/{src → pre-v17/src}/main.server.ts__tmpl__ +0 -0
- /package/src/generators/setup-ssr/files/{base → root}/tsconfig.server.json__tpl__ +0 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setRouterInitialNavigation = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const js_1 = require("@nx/js");
|
|
6
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
7
|
+
const typescript_1 = require("typescript");
|
|
8
|
+
function setRouterInitialNavigation(tree, options) {
|
|
9
|
+
const printer = (0, typescript_1.createPrinter)();
|
|
10
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
11
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, project.root, (filePath) => {
|
|
12
|
+
// we are only interested in .ts files
|
|
13
|
+
if (!filePath.endsWith('.ts')) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (options.standalone) {
|
|
17
|
+
processFileWithStandaloneSetup(tree, filePath, printer);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
processFileWithNgModuleSetup(tree, filePath, printer);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
exports.setRouterInitialNavigation = setRouterInitialNavigation;
|
|
25
|
+
function processFileWithStandaloneSetup(tree, filePath, printer) {
|
|
26
|
+
let content = tree.read(filePath, 'utf-8');
|
|
27
|
+
let sourceFile = tsquery_1.tsquery.ast(content);
|
|
28
|
+
const provideRouterCallExpression = getProvideRouterCallExpression(sourceFile);
|
|
29
|
+
if (!provideRouterCallExpression) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (provideRouterCallExpression.arguments.some((arg) => (0, typescript_1.isCallExpression)(arg) &&
|
|
33
|
+
(0, typescript_1.isIdentifier)(arg.expression) &&
|
|
34
|
+
arg.expression.text === 'withEnabledBlockingInitialNavigation')) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const updatedProvideRouterCallExpression = printer.printNode(typescript_1.EmitHint.Unspecified, updateProvideRouterCallExpression(provideRouterCallExpression), sourceFile);
|
|
38
|
+
content = `${content.slice(0, provideRouterCallExpression.getStart())}${updatedProvideRouterCallExpression}${content.slice(provideRouterCallExpression.getEnd())}`;
|
|
39
|
+
tree.write(filePath, content);
|
|
40
|
+
sourceFile = tsquery_1.tsquery.ast(content);
|
|
41
|
+
sourceFile = (0, js_1.insertImport)(tree, sourceFile, filePath, 'withEnabledBlockingInitialNavigation', '@angular/router');
|
|
42
|
+
const withDisabledInitialNavigationImportNode = (0, tsquery_1.tsquery)(sourceFile, 'ImportDeclaration ImportSpecifier:has(Identifier[name=withDisabledInitialNavigation])')[0];
|
|
43
|
+
if (!withDisabledInitialNavigationImportNode) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const hasTrailingComma = withDisabledInitialNavigationImportNode.parent.elements.hasTrailingComma;
|
|
47
|
+
content = tree.read(filePath, 'utf-8');
|
|
48
|
+
tree.write(filePath, `${content.slice(0, withDisabledInitialNavigationImportNode.getStart())}${content.slice(withDisabledInitialNavigationImportNode.getEnd() +
|
|
49
|
+
(hasTrailingComma ? 1 : 0))}`);
|
|
50
|
+
}
|
|
51
|
+
function updateProvideRouterCallExpression(node) {
|
|
52
|
+
const filteredArgs = node.arguments.filter((arg) => !((0, typescript_1.isCallExpression)(arg) &&
|
|
53
|
+
(0, typescript_1.isIdentifier)(arg.expression) &&
|
|
54
|
+
arg.expression.text === 'withDisabledInitialNavigation'));
|
|
55
|
+
const initialNavigationFeatureArg = typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier('withEnabledBlockingInitialNavigation'), [], []);
|
|
56
|
+
return typescript_1.factory.updateCallExpression(node, node.expression, node.typeArguments, [...filteredArgs, initialNavigationFeatureArg]);
|
|
57
|
+
}
|
|
58
|
+
function processFileWithNgModuleSetup(tree, filePath, printer) {
|
|
59
|
+
const content = tree.read(filePath, 'utf-8');
|
|
60
|
+
const sourceFile = tsquery_1.tsquery.ast(content);
|
|
61
|
+
const routerModuleForRootCallExpression = getRouterModuleForRootCallExpression(sourceFile);
|
|
62
|
+
if (!routerModuleForRootCallExpression) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const updatedRouterModuleForRootCallExpression = printer.printNode(typescript_1.EmitHint.Unspecified, updateRouterModuleForRootCallExpression(routerModuleForRootCallExpression), sourceFile);
|
|
66
|
+
tree.write(filePath, `${content.slice(0, routerModuleForRootCallExpression.getStart())}${updatedRouterModuleForRootCallExpression}${content.slice(routerModuleForRootCallExpression.getEnd())}`);
|
|
67
|
+
}
|
|
68
|
+
function updateRouterModuleForRootCallExpression(node) {
|
|
69
|
+
const existingOptions = node.arguments[1];
|
|
70
|
+
const existingProperties = existingOptions?.properties
|
|
71
|
+
? typescript_1.factory.createNodeArray(existingOptions.properties.filter((exp) => !((0, typescript_1.isPropertyAssignment)(exp) &&
|
|
72
|
+
(0, typescript_1.isIdentifier)(exp.name) &&
|
|
73
|
+
exp.name.text === 'initialNavigation')))
|
|
74
|
+
: typescript_1.factory.createNodeArray();
|
|
75
|
+
const enabledLiteral = typescript_1.factory.createStringLiteral('enabledBlocking');
|
|
76
|
+
const initialNavigationProperty = typescript_1.factory.createPropertyAssignment('initialNavigation', enabledLiteral);
|
|
77
|
+
const routerOptions = existingOptions
|
|
78
|
+
? typescript_1.factory.updateObjectLiteralExpression(existingOptions, typescript_1.factory.createNodeArray([
|
|
79
|
+
...existingProperties,
|
|
80
|
+
initialNavigationProperty,
|
|
81
|
+
]))
|
|
82
|
+
: typescript_1.factory.createObjectLiteralExpression(typescript_1.factory.createNodeArray([initialNavigationProperty]));
|
|
83
|
+
const args = [node.arguments[0], routerOptions];
|
|
84
|
+
return typescript_1.factory.createCallExpression(node.expression, node.typeArguments, args);
|
|
85
|
+
}
|
|
86
|
+
function getProvideRouterCallExpression(sourceFile) {
|
|
87
|
+
const routerModuleForRootCalls = (0, tsquery_1.tsquery)(sourceFile, 'PropertyAssignment:has(Identifier[name=providers]) > ArrayLiteralExpression CallExpression:has(Identifier[name=provideRouter])', { visitAllChildren: true });
|
|
88
|
+
return routerModuleForRootCalls.length ? routerModuleForRootCalls[0] : null;
|
|
89
|
+
}
|
|
90
|
+
function getRouterModuleForRootCallExpression(sourceFile) {
|
|
91
|
+
const routerModuleForRootCalls = (0, tsquery_1.tsquery)(sourceFile, 'Decorator > CallExpression:has(Identifier[name=NgModule]) PropertyAssignment:has(Identifier[name=imports]) > ArrayLiteralExpression CallExpression:has(Identifier[name=forRoot])', { visitAllChildren: true });
|
|
92
|
+
return routerModuleForRootCalls.length ? routerModuleForRootCalls[0] : null;
|
|
93
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { Tree } from '@nx/devkit';
|
|
2
2
|
import type { Schema } from '../schema';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function updateProjectConfigForApplicationBuilder(tree: Tree, options: Schema): void;
|
|
4
|
+
export declare function updateProjectConfigForBrowserBuilder(tree: Tree, schema: Schema): void;
|
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.updateProjectConfigForBrowserBuilder = exports.updateProjectConfigForApplicationBuilder = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const version_utils_1 = require("../../utils/version-utils");
|
|
6
|
+
function updateProjectConfigForApplicationBuilder(tree, options) {
|
|
7
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
8
|
+
const buildTarget = project.targets.build;
|
|
9
|
+
buildTarget.options ??= {};
|
|
10
|
+
buildTarget.options.server = (0, devkit_1.joinPathFragments)(project.sourceRoot ?? (0, devkit_1.joinPathFragments)(project.root, 'src'), options.main);
|
|
11
|
+
buildTarget.options.prerender = true;
|
|
12
|
+
buildTarget.options.ssr = {
|
|
13
|
+
entry: (0, devkit_1.joinPathFragments)(project.root, options.serverFileName),
|
|
14
|
+
};
|
|
15
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
|
|
16
|
+
}
|
|
17
|
+
exports.updateProjectConfigForApplicationBuilder = updateProjectConfigForApplicationBuilder;
|
|
18
|
+
function updateProjectConfigForBrowserBuilder(tree, schema) {
|
|
19
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, schema.project);
|
|
7
20
|
const buildTarget = projectConfig.targets.build;
|
|
8
21
|
const baseOutputPath = buildTarget.options.outputPath;
|
|
9
22
|
buildTarget.options.outputPath = (0, devkit_1.joinPathFragments)(baseOutputPath, 'browser');
|
|
@@ -26,8 +39,11 @@ function updateProjectConfig(tree, schema) {
|
|
|
26
39
|
configurations,
|
|
27
40
|
defaultConfiguration: 'production',
|
|
28
41
|
};
|
|
42
|
+
const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
29
43
|
projectConfig.targets['serve-ssr'] = {
|
|
30
|
-
executor:
|
|
44
|
+
executor: angularMajorVersion >= 17
|
|
45
|
+
? '@angular-devkit/build-angular:ssr-dev-server'
|
|
46
|
+
: '@nguniversal/builders:ssr-dev-server',
|
|
31
47
|
configurations: {
|
|
32
48
|
development: {
|
|
33
49
|
browserTarget: `${schema.project}:build:development`,
|
|
@@ -41,7 +57,9 @@ function updateProjectConfig(tree, schema) {
|
|
|
41
57
|
defaultConfiguration: 'development',
|
|
42
58
|
};
|
|
43
59
|
projectConfig.targets.prerender = {
|
|
44
|
-
executor:
|
|
60
|
+
executor: angularMajorVersion >= 17
|
|
61
|
+
? '@angular-devkit/build-angular:prerender'
|
|
62
|
+
: '@nguniversal/builders:prerender',
|
|
45
63
|
options: {
|
|
46
64
|
routes: ['/'],
|
|
47
65
|
},
|
|
@@ -72,7 +90,7 @@ function updateProjectConfig(tree, schema) {
|
|
|
72
90
|
nxJson.targetDefaults.server.cache ??= true;
|
|
73
91
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
74
92
|
}
|
|
75
|
-
exports.
|
|
93
|
+
exports.updateProjectConfigForBrowserBuilder = updateProjectConfigForBrowserBuilder;
|
|
76
94
|
function getServerOptions(options = {}) {
|
|
77
95
|
return {
|
|
78
96
|
buildOptimizer: options?.buildOptimizer,
|
|
@@ -6,11 +6,24 @@ const validations_1 = require("../../utils/validations");
|
|
|
6
6
|
const version_utils_1 = require("../../utils/version-utils");
|
|
7
7
|
const semver_1 = require("semver");
|
|
8
8
|
function validateOptions(tree, options) {
|
|
9
|
-
|
|
10
|
-
(
|
|
9
|
+
validateProject(tree, options.project);
|
|
10
|
+
validateBuildTarget(tree, options.project);
|
|
11
11
|
validateHydrationOption(tree, options.hydration);
|
|
12
12
|
}
|
|
13
13
|
exports.validateOptions = validateOptions;
|
|
14
|
+
function validateProject(tree, project) {
|
|
15
|
+
(0, validations_1.validateProject)(tree, project);
|
|
16
|
+
const { projectType } = (0, devkit_1.readProjectConfiguration)(tree, project);
|
|
17
|
+
if (projectType !== 'application') {
|
|
18
|
+
throw new Error(`The "${project}" project is not an application. Only application projects are supported by the "setup-ssr" generator.`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function validateBuildTarget(tree, project) {
|
|
22
|
+
const { targets } = (0, devkit_1.readProjectConfiguration)(tree, project);
|
|
23
|
+
if (!targets?.build) {
|
|
24
|
+
throw new Error(`The "${project}" project does not have a "build" target. Please add a "build" target.`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
14
27
|
function validateHydrationOption(tree, hydration) {
|
|
15
28
|
if (!hydration) {
|
|
16
29
|
return;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"appId": {
|
|
20
20
|
"type": "string",
|
|
21
21
|
"format": "html-selector",
|
|
22
|
-
"description": "The `appId` to use with `withServerTransition`. _Note: This is only used in Angular versions <16.0.0. It's deprecated since Angular 16._",
|
|
22
|
+
"description": "The `appId` to use with `withServerTransition`. _Note: This is only used in Angular versions <16.0.0. It's deprecated since Angular 16 and not supported since Angular 17._",
|
|
23
23
|
"default": "serverApp"
|
|
24
24
|
},
|
|
25
25
|
"main": {
|
|
@@ -51,11 +51,11 @@
|
|
|
51
51
|
},
|
|
52
52
|
"standalone": {
|
|
53
53
|
"type": "boolean",
|
|
54
|
-
"description": "Use Standalone Components to bootstrap SSR.
|
|
54
|
+
"description": "Use Standalone Components to bootstrap SSR."
|
|
55
55
|
},
|
|
56
56
|
"hydration": {
|
|
57
57
|
"type": "boolean",
|
|
58
|
-
"description": "Set up Hydration for the SSR application. _Note: This is only supported in Angular versions >= 16.0.0_."
|
|
58
|
+
"description": "Set up Hydration for the SSR application. It defaults to `true` for Angular versions >= 17.0.0. Otherwise, it defaults to `false`. _Note: This is only supported in Angular versions >= 16.0.0_."
|
|
59
59
|
},
|
|
60
60
|
"skipFormat": {
|
|
61
61
|
"type": "boolean",
|
|
@@ -7,24 +7,28 @@ const lib_1 = require("./lib");
|
|
|
7
7
|
async function setupSsr(tree, schema) {
|
|
8
8
|
(0, lib_1.validateOptions)(tree, schema);
|
|
9
9
|
const options = (0, lib_1.normalizeOptions)(tree, schema);
|
|
10
|
-
(0,
|
|
11
|
-
|
|
10
|
+
const { targets } = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
11
|
+
const isUsingApplicationBuilder = targets.build.executor === '@angular-devkit/build-angular:application';
|
|
12
|
+
(0, lib_1.addDependencies)(tree);
|
|
13
|
+
(0, lib_1.generateSSRFiles)(tree, options, isUsingApplicationBuilder);
|
|
12
14
|
if (!options.standalone) {
|
|
13
15
|
(0, lib_1.updateAppModule)(tree, options);
|
|
14
16
|
}
|
|
15
17
|
if (options.hydration) {
|
|
16
18
|
(0, lib_1.addHydration)(tree, options);
|
|
17
19
|
}
|
|
18
|
-
const
|
|
19
|
-
(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
21
|
+
if (angularMajorVersion < 17 || !options.hydration) {
|
|
22
|
+
(0, lib_1.setRouterInitialNavigation)(tree, options);
|
|
23
|
+
}
|
|
24
|
+
if (isUsingApplicationBuilder) {
|
|
25
|
+
(0, lib_1.updateProjectConfigForApplicationBuilder)(tree, options);
|
|
26
|
+
(0, lib_1.setServerTsConfigOptionsForApplicationBuilder)(tree, options);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
(0, lib_1.updateProjectConfigForBrowserBuilder)(tree, options);
|
|
30
|
+
(0, lib_1.generateTsConfigServerJsonForBrowserBuilder)(tree, options);
|
|
31
|
+
}
|
|
28
32
|
if (!options.skipFormat) {
|
|
29
33
|
await (0, devkit_1.formatFiles)(tree);
|
|
30
34
|
}
|
|
@@ -3,15 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createTsConfig = exports.extractTsConfigBase = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const js_1 = require("@nx/js");
|
|
6
|
-
const version_utils_1 = require("./version-utils");
|
|
7
6
|
var js_2 = require("@nx/js");
|
|
8
7
|
Object.defineProperty(exports, "extractTsConfigBase", { enumerable: true, get: function () { return js_2.extractTsConfigBase; } });
|
|
9
8
|
function createTsConfig(host, projectRoot, type, options, relativePathToRootTsConfig) {
|
|
10
|
-
const majorAngularVersion = (0, version_utils_1.getInstalledAngularMajorVersion)(host);
|
|
11
9
|
const json = {
|
|
12
10
|
compilerOptions: {
|
|
13
|
-
target:
|
|
11
|
+
target: 'es2022',
|
|
14
12
|
useDefineForClassFields: false,
|
|
13
|
+
esModuleInterop: options.esModuleInterop ? true : undefined,
|
|
15
14
|
},
|
|
16
15
|
files: [],
|
|
17
16
|
include: [],
|
|
@@ -54,10 +54,12 @@ async function createStorybookTestWorkspaceForLib(libName) {
|
|
|
54
54
|
skipFormat: false,
|
|
55
55
|
unitTestRunner: test_runners_1.UnitTestRunner.Jest,
|
|
56
56
|
projectNameAndRootFormat: 'as-provided',
|
|
57
|
+
standalone: false,
|
|
57
58
|
});
|
|
58
59
|
await (0, component_1.componentGenerator)(tree, {
|
|
59
60
|
name: 'test-button',
|
|
60
61
|
project: libName,
|
|
62
|
+
standalone: false,
|
|
61
63
|
});
|
|
62
64
|
tree.write(`${libName}/src/lib/test-button/test-button.component.ts`, `import { Component, Input } from '@angular/core';
|
|
63
65
|
|
|
@@ -88,6 +90,7 @@ export class TestButtonComponent {
|
|
|
88
90
|
project: libName,
|
|
89
91
|
path: `${libName}/src/lib/barrel`,
|
|
90
92
|
module: 'barrel',
|
|
93
|
+
standalone: false,
|
|
91
94
|
});
|
|
92
95
|
tree.write(`${libName}/src/lib/barrel/barrel-button/index.ts`, `export * from './barrel-button.component';`);
|
|
93
96
|
tree.write(`${libName}/src/lib/barrel/barrel.module.ts`, `import { NgModule } from '@angular/core';
|
|
@@ -109,12 +112,14 @@ export class BarrelModule {}`);
|
|
|
109
112
|
project: libName,
|
|
110
113
|
path: `${libName}/src/lib/variable-declare`,
|
|
111
114
|
module: 'variable-declare',
|
|
115
|
+
standalone: false,
|
|
112
116
|
});
|
|
113
117
|
await (0, component_1.componentGenerator)(tree, {
|
|
114
118
|
name: 'variable-declare-view',
|
|
115
119
|
project: libName,
|
|
116
120
|
path: `${libName}/src/lib/variable-declare`,
|
|
117
121
|
module: 'variable-declare',
|
|
122
|
+
standalone: false,
|
|
118
123
|
});
|
|
119
124
|
tree.write(`${libName}/src/lib/variable-declare/variable-declare.module.ts`, `import { NgModule } from '@angular/core';
|
|
120
125
|
import { CommonModule } from '@angular/common';
|
|
@@ -142,18 +147,21 @@ export class VariableDeclareModule {}`);
|
|
|
142
147
|
project: libName,
|
|
143
148
|
path: `${libName}/src/lib/variable-spread-declare`,
|
|
144
149
|
module: 'variable-spread-declare',
|
|
150
|
+
standalone: false,
|
|
145
151
|
});
|
|
146
152
|
await (0, component_1.componentGenerator)(tree, {
|
|
147
153
|
name: 'variable-spread-declare-view',
|
|
148
154
|
project: libName,
|
|
149
155
|
path: `${libName}/src/lib/variable-spread-declare`,
|
|
150
156
|
module: 'variable-spread-declare',
|
|
157
|
+
standalone: false,
|
|
151
158
|
});
|
|
152
159
|
await (0, component_1.componentGenerator)(tree, {
|
|
153
160
|
name: 'variable-spread-declare-anotherview',
|
|
154
161
|
project: libName,
|
|
155
162
|
path: `${libName}/src/lib/variable-spread-declare`,
|
|
156
163
|
module: 'variable-spread-declare',
|
|
164
|
+
standalone: false,
|
|
157
165
|
});
|
|
158
166
|
tree.write(`${libName}/src/lib/variable-spread-declare/variable-spread-declare.module.ts`, `import { NgModule } from '@angular/core';
|
|
159
167
|
import { CommonModule } from '@angular/common';
|
|
@@ -181,12 +189,14 @@ export class VariableSpreadDeclareModule {}`);
|
|
|
181
189
|
project: libName,
|
|
182
190
|
path: `${libName}/src/lib/static-member-declarations`,
|
|
183
191
|
module: 'static-member-declarations',
|
|
192
|
+
standalone: false,
|
|
184
193
|
});
|
|
185
194
|
await (0, component_1.componentGenerator)(tree, {
|
|
186
195
|
name: 'cmp2',
|
|
187
196
|
project: libName,
|
|
188
197
|
path: `${libName}/src/lib/static-member-declarations`,
|
|
189
198
|
module: 'static-member-declarations',
|
|
199
|
+
standalone: false,
|
|
190
200
|
});
|
|
191
201
|
tree.write(`${libName}/src/lib/static-member-declarations/static-member-declarations.module.ts`, `import { NgModule } from '@angular/core';
|
|
192
202
|
import { CommonModule } from '@angular/common';
|
|
@@ -212,10 +222,12 @@ export class StaticMemberDeclarationsModule {
|
|
|
212
222
|
project: libName,
|
|
213
223
|
module: 'nested',
|
|
214
224
|
path: `${libName}/src/lib/nested`,
|
|
225
|
+
standalone: false,
|
|
215
226
|
});
|
|
216
227
|
await (0, component_1.componentGenerator)(tree, {
|
|
217
228
|
name: 'test-other',
|
|
218
229
|
project: libName,
|
|
230
|
+
standalone: false,
|
|
219
231
|
});
|
|
220
232
|
return tree;
|
|
221
233
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.validateProject = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const semver_1 = require("semver");
|
|
6
|
-
const version_utils_1 = require("./version-utils");
|
|
7
5
|
function validateProject(tree, projectName) {
|
|
8
6
|
const projects = (0, devkit_1.getProjects)(tree);
|
|
9
7
|
if (!projects.has(projectName)) {
|
|
@@ -11,14 +9,3 @@ function validateProject(tree, projectName) {
|
|
|
11
9
|
}
|
|
12
10
|
}
|
|
13
11
|
exports.validateProject = validateProject;
|
|
14
|
-
function validateStandaloneOption(tree, standalone, angularVersion) {
|
|
15
|
-
if (!standalone) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
const installedAngularVersion = angularVersion ?? (0, version_utils_1.getInstalledAngularVersionInfo)(tree).version;
|
|
19
|
-
if ((0, semver_1.lt)(installedAngularVersion, '14.1.0')) {
|
|
20
|
-
throw new Error((0, devkit_1.stripIndents) `The "standalone" option is only supported in Angular >= 14.1.0. You are currently using "${installedAngularVersion}".
|
|
21
|
-
You can resolve this error by removing the "standalone" option or by migrating to Angular 14.1.0.`);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.validateStandaloneOption = validateStandaloneOption;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
|
-
import
|
|
2
|
+
import { type PackageCompatVersions, type PackageLatestVersions } from '../../utils/backward-compatible-versions';
|
|
3
3
|
export declare function getInstalledAngularVersion(tree: Tree): string;
|
|
4
4
|
export declare function getInstalledAngularMajorVersion(tree: Tree): number;
|
|
5
5
|
export declare function getInstalledAngularVersionInfo(tree: Tree): {
|
|
@@ -12,4 +12,4 @@ export declare function getInstalledPackageVersionInfo(tree: Tree, pkgName: stri
|
|
|
12
12
|
version: string;
|
|
13
13
|
};
|
|
14
14
|
export declare function addDependenciesToPackageJsonIfDontExist(tree: Tree, dependencies: Record<string, string>, devDependencies: Record<string, string>, packageJsonPath?: string): GeneratorCallback;
|
|
15
|
-
export declare function versions(tree: Tree):
|
|
15
|
+
export declare function versions(tree: Tree): PackageLatestVersions | PackageCompatVersions;
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.versions = exports.addDependenciesToPackageJsonIfDontExist = exports.getInstalledPackageVersionInfo = exports.getInstalledPackageVersion = exports.getInstalledAngularVersionInfo = exports.getInstalledAngularMajorVersion = exports.getInstalledAngularVersion = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const semver_1 = require("semver");
|
|
6
|
+
const backward_compatible_versions_1 = require("../../utils/backward-compatible-versions");
|
|
6
7
|
const latestVersions = require("../../utils/versions");
|
|
7
8
|
const versions_1 = require("../../utils/versions");
|
|
8
|
-
const backward_compatible_versions_1 = require("../../utils/backward-compatible-versions");
|
|
9
9
|
function getInstalledAngularVersion(tree) {
|
|
10
10
|
const pkgJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
11
11
|
const installedAngularVersion = pkgJson.dependencies && pkgJson.dependencies['@angular/core'];
|
|
@@ -55,10 +55,10 @@ exports.addDependenciesToPackageJsonIfDontExist = addDependenciesToPackageJsonIf
|
|
|
55
55
|
function versions(tree) {
|
|
56
56
|
const majorAngularVersion = getInstalledAngularMajorVersion(tree);
|
|
57
57
|
switch (majorAngularVersion) {
|
|
58
|
-
case 14:
|
|
59
|
-
return backward_compatible_versions_1.backwardCompatibleVersions.angularV14;
|
|
60
58
|
case 15:
|
|
61
59
|
return backward_compatible_versions_1.backwardCompatibleVersions.angularV15;
|
|
60
|
+
case 16:
|
|
61
|
+
return backward_compatible_versions_1.backwardCompatibleVersions.angularV16;
|
|
62
62
|
default:
|
|
63
63
|
return latestVersions;
|
|
64
64
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executors = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
+
exports.executors = [
|
|
7
|
+
'@angular-devkit/build-angular:dev-server',
|
|
8
|
+
'@angular-devkit/build-angular:extract-i18n',
|
|
9
|
+
'@nx/angular:module-federation-dev-server',
|
|
10
|
+
'@nx/angular:webpack-dev-server',
|
|
11
|
+
];
|
|
12
|
+
async function default_1(tree) {
|
|
13
|
+
// update options from project configs
|
|
14
|
+
exports.executors.forEach((executor) => {
|
|
15
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, executor, (_, project, target, configuration) => {
|
|
16
|
+
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, project);
|
|
17
|
+
const config = configuration
|
|
18
|
+
? projectConfiguration.targets[target].configurations[configuration]
|
|
19
|
+
: projectConfiguration.targets[target].options;
|
|
20
|
+
updateConfig(config);
|
|
21
|
+
(0, devkit_1.updateProjectConfiguration)(tree, project, projectConfiguration);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
// update options from nx.json target defaults
|
|
25
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
26
|
+
if (!nxJson.targetDefaults) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
for (const [targetOrExecutor, targetConfig] of Object.entries(nxJson.targetDefaults)) {
|
|
30
|
+
if (!exports.executors.includes(targetOrExecutor) &&
|
|
31
|
+
!exports.executors.includes(targetConfig.executor)) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (targetConfig.options) {
|
|
35
|
+
updateConfig(targetConfig.options);
|
|
36
|
+
}
|
|
37
|
+
Object.values(targetConfig.configurations ?? {}).forEach((config) => {
|
|
38
|
+
updateConfig(config);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
42
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
43
|
+
}
|
|
44
|
+
exports.default = default_1;
|
|
45
|
+
function updateConfig(config) {
|
|
46
|
+
if (config.browserTarget) {
|
|
47
|
+
config.buildTarget ??= config.browserTarget;
|
|
48
|
+
delete config.browserTarget;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
async function default_1(tree) {
|
|
5
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
6
|
+
for (const [, project] of projects) {
|
|
7
|
+
if (project.projectType !== 'application') {
|
|
8
|
+
continue;
|
|
9
|
+
}
|
|
10
|
+
for (const target of Object.values(project.targets ?? {})) {
|
|
11
|
+
if (target.executor === '@nguniversal/builders:ssr-dev-server') {
|
|
12
|
+
target.executor = '@angular-devkit/build-angular:ssr-dev-server';
|
|
13
|
+
}
|
|
14
|
+
else if (target.executor === '@nguniversal/builders:prerender') {
|
|
15
|
+
target.executor = '@angular-devkit/build-angular:prerender';
|
|
16
|
+
updatePrerenderOptions(target);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
(0, devkit_1.updateProjectConfiguration)(tree, project.name, project);
|
|
20
|
+
}
|
|
21
|
+
// update options from nx.json target defaults
|
|
22
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
23
|
+
if (!nxJson.targetDefaults) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
for (const [targetOrExecutor, targetConfig] of Object.entries(nxJson.targetDefaults)) {
|
|
27
|
+
if (targetOrExecutor === '@nguniversal/builders:ssr-dev-server') {
|
|
28
|
+
nxJson.targetDefaults['@angular-devkit/build-angular:ssr-dev-server'] =
|
|
29
|
+
targetConfig;
|
|
30
|
+
delete nxJson.targetDefaults['@nguniversal/builders:ssr-dev-server'];
|
|
31
|
+
}
|
|
32
|
+
else if (targetOrExecutor === '@nguniversal/builders:prerender') {
|
|
33
|
+
nxJson.targetDefaults['@angular-devkit/build-angular:prerender'] =
|
|
34
|
+
targetConfig;
|
|
35
|
+
delete nxJson.targetDefaults['@nguniversal/builders:prerender'];
|
|
36
|
+
updatePrerenderOptions(targetConfig);
|
|
37
|
+
}
|
|
38
|
+
else if (targetConfig.executor === '@nguniversal/builders:ssr-dev-server') {
|
|
39
|
+
targetConfig.executor = '@angular-devkit/build-angular:ssr-dev-server';
|
|
40
|
+
}
|
|
41
|
+
else if (targetConfig.executor === '@nguniversal/builders:prerender') {
|
|
42
|
+
targetConfig.executor = '@angular-devkit/build-angular:prerender';
|
|
43
|
+
updatePrerenderOptions(targetConfig);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
47
|
+
// remove @nguniversal/builders from package.json
|
|
48
|
+
(0, devkit_1.removeDependenciesFromPackageJson)(tree, ['@nguniversal/builders'], ['@nguniversal/builders']);
|
|
49
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
50
|
+
}
|
|
51
|
+
exports.default = default_1;
|
|
52
|
+
function* allTargetOptions(target) {
|
|
53
|
+
if (target.options) {
|
|
54
|
+
yield [undefined, target.options];
|
|
55
|
+
}
|
|
56
|
+
if (!target.configurations) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
for (const [name, options] of Object.entries(target.configurations)) {
|
|
60
|
+
if (options !== undefined) {
|
|
61
|
+
yield [name, options];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function updatePrerenderOptions(config) {
|
|
66
|
+
for (const [, options] of allTargetOptions(config)) {
|
|
67
|
+
if (options.guessRoutes !== undefined) {
|
|
68
|
+
options.discoverRoutes = options.guessRoutes;
|
|
69
|
+
delete options.guessRoutes;
|
|
70
|
+
}
|
|
71
|
+
if (options.numProcesses !== undefined) {
|
|
72
|
+
delete options.numProcesses;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|