@nx/angular 17.3.0 → 17.3.1
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.d.ts +1 -1
- package/generators.json +6 -1
- package/package.json +10 -10
- package/src/builders/dev-server/dev-server.impl.js +1 -1
- package/src/builders/dev-server/schema.json +1 -1
- package/src/executors/module-federation-dev-server/schema.json +1 -1
- package/src/executors/ng-packagr-lite/schema.json +1 -1
- package/src/executors/package/schema.json +1 -1
- package/src/generators/add-linting/schema.json +1 -1
- package/src/generators/application/schema.json +4 -4
- package/src/generators/component/schema.d.ts +3 -3
- package/src/generators/component/schema.json +2 -2
- package/src/generators/component-cypress-spec/schema.json +1 -1
- package/src/generators/component-test/schema.json +1 -1
- package/src/generators/convert-to-application-executor/convert-to-application-executor.d.ts +4 -0
- package/src/generators/convert-to-application-executor/convert-to-application-executor.js +240 -0
- package/src/generators/convert-to-application-executor/schema.d.ts +4 -0
- package/src/generators/convert-to-application-executor/schema.json +26 -0
- package/src/generators/directive/schema.d.ts +3 -3
- package/src/generators/directive/schema.json +2 -2
- package/src/generators/federate-module/schema.json +1 -1
- package/src/generators/host/schema.json +4 -4
- package/src/generators/init/schema.json +1 -1
- package/src/generators/library/schema.json +1 -1
- package/src/generators/library-secondary-entry-point/schema.json +1 -1
- package/src/generators/move/schema.json +1 -1
- package/src/generators/ng-add/schema.json +1 -1
- package/src/generators/ngrx/schema.json +1 -1
- package/src/generators/ngrx-feature-store/schema.json +1 -1
- package/src/generators/ngrx-root-store/schema.json +1 -1
- package/src/generators/pipe/schema.d.ts +3 -3
- package/src/generators/pipe/schema.json +2 -2
- package/src/generators/remote/schema.json +4 -4
- package/src/generators/scam/schema.d.ts +3 -3
- package/src/generators/scam/schema.json +2 -2
- package/src/generators/scam-directive/schema.d.ts +3 -3
- package/src/generators/scam-directive/schema.json +2 -2
- package/src/generators/scam-pipe/schema.d.ts +3 -3
- package/src/generators/scam-pipe/schema.json +2 -2
- package/src/generators/scam-to-standalone/schema.json +1 -1
- package/src/generators/setup-mf/schema.json +1 -1
- package/src/generators/setup-ssr/lib/add-hydration.js +11 -5
- package/src/generators/setup-ssr/lib/update-project-config.js +3 -1
- package/src/generators/setup-ssr/schema.json +1 -1
- package/src/generators/setup-ssr/setup-ssr.js +2 -1
- package/src/generators/setup-tailwind/schema.json +1 -1
- package/src/generators/stories/schema.json +1 -1
- package/src/generators/storybook-configuration/schema.json +4 -4
- package/src/generators/storybook-configuration/storybook-configuration.js +1 -1
- package/src/migrations/update-17-1-0/replace-nguniversal-engines.js +2 -14
- package/src/utils/targets.d.ts +2 -0
- package/src/utils/targets.js +17 -0
package/executors.d.ts
CHANGED
|
@@ -10,6 +10,6 @@ export * from './src/executors/application/application.impl';
|
|
|
10
10
|
import { executeDevServerBuilder } from './src/builders/dev-server/dev-server.impl';
|
|
11
11
|
export {
|
|
12
12
|
/**
|
|
13
|
-
* @deprecated Use executeDevServerBuilder instead. It will be removed in Nx
|
|
13
|
+
* @deprecated Use executeDevServerBuilder instead. It will be removed in Nx v19.
|
|
14
14
|
*/
|
|
15
15
|
executeDevServerBuilder as executeWebpackDevServerBuilder, executeDevServerBuilder, };
|
package/generators.json
CHANGED
|
@@ -39,6 +39,11 @@
|
|
|
39
39
|
"schema": "./src/generators/component-test/schema.json",
|
|
40
40
|
"description": "Creates a cypress component test file for a component."
|
|
41
41
|
},
|
|
42
|
+
"convert-to-application-executor": {
|
|
43
|
+
"factory": "./src/generators/convert-to-application-executor/convert-to-application-executor",
|
|
44
|
+
"schema": "./src/generators/convert-to-application-executor/schema.json",
|
|
45
|
+
"description": "Converts projects to use the `@nx/angular:application` executor or the `@angular-devkit/build-angular:application` builder. _Note: this is only supported in Angular versions >= 17.0.0_."
|
|
46
|
+
},
|
|
42
47
|
"directive": {
|
|
43
48
|
"factory": "./src/generators/directive/directive",
|
|
44
49
|
"schema": "./src/generators/directive/schema.json",
|
|
@@ -81,7 +86,7 @@
|
|
|
81
86
|
"schema": "./src/generators/move/schema.json",
|
|
82
87
|
"aliases": ["mv"],
|
|
83
88
|
"description": "Moves an Angular application or library to another folder within the workspace and updates the project configuration.",
|
|
84
|
-
"x-deprecated": "Use the `@nx/workspace:move` generator instead. This generator will be removed in Nx
|
|
89
|
+
"x-deprecated": "Use the `@nx/workspace:move` generator instead. This generator will be removed in Nx v19."
|
|
85
90
|
},
|
|
86
91
|
"convert-to-with-mf": {
|
|
87
92
|
"factory": "./src/generators/convert-to-with-mf/convert-to-with-mf",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/angular",
|
|
3
|
-
"version": "17.3.
|
|
3
|
+
"version": "17.3.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: \n\n- Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, and Cypress. \n\n- Generators to help scaffold code quickly (like: Micro Frontends, Libraries, both internal to your codebase and publishable to npm) \n\n- Upgrading AngularJS applications \n\n- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
|
|
6
6
|
"repository": {
|
|
@@ -78,16 +78,16 @@
|
|
|
78
78
|
"tslib": "^2.3.0",
|
|
79
79
|
"webpack": "^5.80.0",
|
|
80
80
|
"webpack-merge": "^5.8.0",
|
|
81
|
-
"@nx/devkit": "17.3.
|
|
82
|
-
"@nx/cypress": "17.3.
|
|
83
|
-
"@nx/jest": "17.3.
|
|
84
|
-
"@nx/js": "17.3.
|
|
85
|
-
"@nx/eslint": "17.3.
|
|
86
|
-
"@nx/webpack": "17.3.
|
|
87
|
-
"@nx/web": "17.3.
|
|
88
|
-
"@nx/workspace": "17.3.
|
|
81
|
+
"@nx/devkit": "17.3.1",
|
|
82
|
+
"@nx/cypress": "17.3.1",
|
|
83
|
+
"@nx/jest": "17.3.1",
|
|
84
|
+
"@nx/js": "17.3.1",
|
|
85
|
+
"@nx/eslint": "17.3.1",
|
|
86
|
+
"@nx/webpack": "17.3.1",
|
|
87
|
+
"@nx/web": "17.3.1",
|
|
88
|
+
"@nx/workspace": "17.3.1",
|
|
89
89
|
"piscina": "^4.2.1",
|
|
90
|
-
"@nrwl/angular": "17.3.
|
|
90
|
+
"@nrwl/angular": "17.3.1"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
93
|
"@angular-devkit/build-angular": ">= 15.0.0 < 18.0.0",
|
|
@@ -16,7 +16,7 @@ const buildable_libs_1 = require("../utilities/buildable-libs");
|
|
|
16
16
|
const webpack_1 = require("../utilities/webpack");
|
|
17
17
|
const lib_1 = require("./lib");
|
|
18
18
|
function executeDevServerBuilder(rawOptions, context) {
|
|
19
|
-
if (rawOptions.esbuildMiddleware) {
|
|
19
|
+
if (rawOptions.esbuildMiddleware?.length > 0) {
|
|
20
20
|
const { major: angularMajorVersion, version: angularVersion } = (0, angular_version_utils_1.getInstalledAngularVersionInfo)();
|
|
21
21
|
if (angularMajorVersion < 17) {
|
|
22
22
|
throw new Error((0, devkit_1.stripIndents) `The "esbuildMiddleware" option is only supported in Angular >= 17.0.0. You are currently using "${angularVersion}".
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"type": "string",
|
|
18
18
|
"description": "A browser builder target to serve in the format of `project:target[:configuration]`. Ignored if `buildTarget` is set.",
|
|
19
19
|
"pattern": "^[^:\\s]+:[^:\\s]+(:[^\\s]+)?$",
|
|
20
|
-
"x-deprecated": "Use 'buildTarget' instead. It will be removed in Nx
|
|
20
|
+
"x-deprecated": "Use 'buildTarget' instead. It will be removed in Nx v19."
|
|
21
21
|
},
|
|
22
22
|
"buildTarget": {
|
|
23
23
|
"type": "string",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"type": "string",
|
|
16
16
|
"description": "A browser builder target to serve in the format of `project:target[:configuration]`.",
|
|
17
17
|
"pattern": "^[^:\\s]+:[^:\\s]+(:[^\\s]+)?$",
|
|
18
|
-
"x-deprecated": "Use 'buildTarget' instead. It will be removed in Nx
|
|
18
|
+
"x-deprecated": "Use 'buildTarget' instead. It will be removed in Nx v19."
|
|
19
19
|
},
|
|
20
20
|
"buildTarget": {
|
|
21
21
|
"type": "string",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 2,
|
|
3
3
|
"outputCapture": "direct-nodejs",
|
|
4
|
-
"$schema": "
|
|
4
|
+
"$schema": "https://json-schema.org/schema",
|
|
5
5
|
"title": "ng-packagr Target",
|
|
6
6
|
"description": "Builds a library with support for incremental builds.\n\nThis executor is meant to be used with buildable libraries in an incremental build scenario. It is similar to the `@nx/angular:package` executor but with some key differences:\n- For supported Angular versions lower than v16, it doesn't run `ngcc` automatically (`ngcc` is no longer available from Angular v16 onwards, for lower versions, it needs to be run separately beforehand if needed, this can be done in a `postinstall` hook on `package.json`).\n- It only produces ESM2022 bundles (ESM2020 for supported Angular versions lower than v16).",
|
|
7
7
|
"cli": "nx",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 2,
|
|
3
3
|
"outputCapture": "direct-nodejs",
|
|
4
|
-
"$schema": "
|
|
4
|
+
"$schema": "https://json-schema.org/schema",
|
|
5
5
|
"title": "ng-packagr Target",
|
|
6
6
|
"description": "Builds and packages an Angular library producing an output following the Angular Package Format (APF) to be distributed as an NPM package.\n\nThis executor is similar to the `@angular-devkit/build-angular:ng-packagr` with additional support for incremental builds.",
|
|
7
7
|
"cli": "nx",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"$id": "GeneratorNxApp",
|
|
4
4
|
"title": "Creates an Angular application.",
|
|
5
5
|
"description": "Creates an Angular application.",
|
|
@@ -41,15 +41,15 @@
|
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
43
|
"value": "scss",
|
|
44
|
-
"label": "SASS(.scss) [
|
|
44
|
+
"label": "SASS(.scss) [ https://sass-lang.com ]"
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
"value": "sass",
|
|
48
|
-
"label": "SASS(.sass) [
|
|
48
|
+
"label": "SASS(.sass) [ https://sass-lang.com ]"
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
"value": "less",
|
|
52
|
-
"label": "LESS [
|
|
52
|
+
"label": "LESS [ https://lesscss.org ]"
|
|
53
53
|
}
|
|
54
54
|
]
|
|
55
55
|
}
|
|
@@ -22,15 +22,15 @@ export interface Schema {
|
|
|
22
22
|
skipFormat?: boolean;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx
|
|
25
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.
|
|
26
26
|
*/
|
|
27
27
|
flat?: boolean;
|
|
28
28
|
/**
|
|
29
|
-
* @deprecated Provide the `directory` option instead. It will be removed in Nx
|
|
29
|
+
* @deprecated Provide the `directory` option instead. It will be removed in Nx v19.
|
|
30
30
|
*/
|
|
31
31
|
path?: string;
|
|
32
32
|
/**
|
|
33
|
-
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx
|
|
33
|
+
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v19.
|
|
34
34
|
*/
|
|
35
35
|
project?: string;
|
|
36
36
|
}
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"$source": "projectName"
|
|
35
35
|
},
|
|
36
36
|
"x-dropdown": "projects",
|
|
37
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx
|
|
37
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19."
|
|
38
38
|
},
|
|
39
39
|
"prefix": {
|
|
40
40
|
"type": "string",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"type": "boolean",
|
|
99
99
|
"description": "Create the new files at the top level of the current project.",
|
|
100
100
|
"default": false,
|
|
101
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx
|
|
101
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19."
|
|
102
102
|
},
|
|
103
103
|
"skipImport": {
|
|
104
104
|
"type": "boolean",
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertToApplicationExecutor = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const posix_1 = require("node:path/posix");
|
|
6
|
+
const semver_1 = require("semver");
|
|
7
|
+
const targets_1 = require("../../utils/targets");
|
|
8
|
+
const setup_ssr_1 = require("../setup-ssr/setup-ssr");
|
|
9
|
+
const validations_1 = require("../utils/validations");
|
|
10
|
+
const version_utils_1 = require("../utils/version-utils");
|
|
11
|
+
const executorsToConvert = new Set([
|
|
12
|
+
'@angular-devkit/build-angular:browser',
|
|
13
|
+
'@angular-devkit/build-angular:browser-esbuild',
|
|
14
|
+
'@nx/angular:webpack-browser',
|
|
15
|
+
'@nx/angular:browser-esbuild',
|
|
16
|
+
]);
|
|
17
|
+
const serverTargetExecutors = new Set([
|
|
18
|
+
'@angular-devkit/build-angular:server',
|
|
19
|
+
'@nx/angular:webpack-server',
|
|
20
|
+
]);
|
|
21
|
+
const redundantExecutors = new Set([
|
|
22
|
+
'@angular-devkit/build-angular:server',
|
|
23
|
+
'@angular-devkit/build-angular:prerender',
|
|
24
|
+
'@angular-devkit/build-angular:app-shell',
|
|
25
|
+
'@angular-devkit/build-angular:ssr-dev-server',
|
|
26
|
+
'@nx/angular:webpack-server',
|
|
27
|
+
]);
|
|
28
|
+
async function convertToApplicationExecutor(tree, options) {
|
|
29
|
+
const { major: angularMajorVersion, version: angularVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
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
|
+
}
|
|
33
|
+
let didAnySucceed = false;
|
|
34
|
+
if (options.project) {
|
|
35
|
+
(0, validations_1.validateProject)(tree, options.project);
|
|
36
|
+
didAnySucceed = await convertProjectTargets(tree, options.project, angularVersion, true);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
40
|
+
for (const [projectName] of projects) {
|
|
41
|
+
devkit_1.logger.info(`Converting project "${projectName}"...`);
|
|
42
|
+
const success = await convertProjectTargets(tree, projectName, angularVersion);
|
|
43
|
+
if (success) {
|
|
44
|
+
devkit_1.logger.info(`Project "${projectName}" converted successfully.`);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
devkit_1.logger.info(`Project "${projectName}" could not be converted. See above for more information.`);
|
|
48
|
+
}
|
|
49
|
+
devkit_1.logger.info('');
|
|
50
|
+
didAnySucceed = didAnySucceed || success;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (!options.skipFormat) {
|
|
54
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
55
|
+
}
|
|
56
|
+
return didAnySucceed ? () => (0, devkit_1.installPackagesTask)(tree) : () => { };
|
|
57
|
+
}
|
|
58
|
+
exports.convertToApplicationExecutor = convertToApplicationExecutor;
|
|
59
|
+
async function convertProjectTargets(tree, projectName, angularVersion, isProvidedProject = false) {
|
|
60
|
+
function warnIfProvided(message) {
|
|
61
|
+
if (isProvidedProject) {
|
|
62
|
+
devkit_1.logger.warn(message);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
let project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
66
|
+
if (project.projectType !== 'application') {
|
|
67
|
+
warnIfProvided(`The provided project "${projectName}" is not an application. Skipping conversion.`);
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
const { buildTargetName, serverTargetName } = getTargetsToConvert(project.targets);
|
|
71
|
+
if (!buildTargetName) {
|
|
72
|
+
warnIfProvided(`The provided project "${projectName}" does not have any targets using on of the ` +
|
|
73
|
+
`'@angular-devkit/build-angular:browser', '@angular-devkit/build-angular:browser-esbuild', ` +
|
|
74
|
+
`'@nx/angular:browser' and '@nx/angular:browser-esbuild' executors. Skipping conversion.`);
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
const useNxExecutor = project.targets[buildTargetName].executor.startsWith('@nx/angular:');
|
|
78
|
+
const newExecutor = useNxExecutor
|
|
79
|
+
? '@nx/angular:application'
|
|
80
|
+
: '@angular-devkit/build-angular:application';
|
|
81
|
+
const buildTarget = project.targets[buildTargetName];
|
|
82
|
+
buildTarget.executor = newExecutor;
|
|
83
|
+
if ((0, semver_1.gte)(angularVersion, '17.1.0') && buildTarget.outputs) {
|
|
84
|
+
buildTarget.outputs = buildTarget.outputs.map((output) => output === '{options.outputPath}' ? '{options.outputPath.base}' : output);
|
|
85
|
+
}
|
|
86
|
+
for (const [, options] of (0, targets_1.allTargetOptions)(buildTarget)) {
|
|
87
|
+
if (options['index'] === '') {
|
|
88
|
+
options['index'] = false;
|
|
89
|
+
}
|
|
90
|
+
// Rename and transform options
|
|
91
|
+
options['browser'] = options['main'];
|
|
92
|
+
if (serverTargetName && typeof options['browser'] === 'string') {
|
|
93
|
+
options['server'] = (0, posix_1.dirname)(options['browser']) + '/main.server.ts';
|
|
94
|
+
}
|
|
95
|
+
options['serviceWorker'] =
|
|
96
|
+
options['ngswConfigPath'] ?? options['serviceWorker'];
|
|
97
|
+
if (typeof options['polyfills'] === 'string') {
|
|
98
|
+
options['polyfills'] = [options['polyfills']];
|
|
99
|
+
}
|
|
100
|
+
let outputPath = options['outputPath'];
|
|
101
|
+
if ((0, semver_1.lt)(angularVersion, '17.1.0')) {
|
|
102
|
+
options['outputPath'] = outputPath?.replace(/\/browser\/?$/, '');
|
|
103
|
+
}
|
|
104
|
+
else if (typeof outputPath === 'string') {
|
|
105
|
+
if (!/\/browser\/?$/.test(outputPath)) {
|
|
106
|
+
devkit_1.logger.warn(`The output location of the browser build has been updated from "${outputPath}" to ` +
|
|
107
|
+
`"${(0, posix_1.join)(outputPath, 'browser')}". ` +
|
|
108
|
+
'You might need to adjust your deployment pipeline or, as an alternative, ' +
|
|
109
|
+
'set outputPath.browser to "" in order to maintain the previous functionality.');
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
outputPath = outputPath.replace(/\/browser\/?$/, '');
|
|
113
|
+
}
|
|
114
|
+
options['outputPath'] = {
|
|
115
|
+
base: outputPath,
|
|
116
|
+
};
|
|
117
|
+
if (typeof options['resourcesOutputPath'] === 'string') {
|
|
118
|
+
const media = options['resourcesOutputPath'].replaceAll('/', '');
|
|
119
|
+
if (media && media !== 'media') {
|
|
120
|
+
options['outputPath'] = {
|
|
121
|
+
base: outputPath,
|
|
122
|
+
media: media,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// Delete removed options
|
|
128
|
+
delete options['deployUrl'];
|
|
129
|
+
delete options['vendorChunk'];
|
|
130
|
+
delete options['commonChunk'];
|
|
131
|
+
delete options['resourcesOutputPath'];
|
|
132
|
+
delete options['buildOptimizer'];
|
|
133
|
+
delete options['main'];
|
|
134
|
+
delete options['ngswConfigPath'];
|
|
135
|
+
}
|
|
136
|
+
// Merge browser and server tsconfig
|
|
137
|
+
if (serverTargetName) {
|
|
138
|
+
const browserTsConfigPath = buildTarget?.options?.tsConfig;
|
|
139
|
+
const serverTsConfigPath = project.targets['server']?.options?.tsConfig;
|
|
140
|
+
if (typeof browserTsConfigPath !== 'string') {
|
|
141
|
+
devkit_1.logger.warn(`Cannot update project "${projectName}" to use the application executor ` +
|
|
142
|
+
`as the browser tsconfig cannot be located.`);
|
|
143
|
+
}
|
|
144
|
+
if (typeof serverTsConfigPath !== 'string') {
|
|
145
|
+
devkit_1.logger.warn(`Cannot update project "${projectName}" to use the application executor ` +
|
|
146
|
+
`as the server tsconfig cannot be located.`);
|
|
147
|
+
}
|
|
148
|
+
const browserTsConfigJson = (0, devkit_1.readJson)(tree, browserTsConfigPath);
|
|
149
|
+
const serverTsConfigJson = (0, devkit_1.readJson)(tree, serverTsConfigPath);
|
|
150
|
+
const files = new Set([
|
|
151
|
+
...(browserTsConfigJson.files ?? []),
|
|
152
|
+
...(serverTsConfigJson.files ?? []),
|
|
153
|
+
]);
|
|
154
|
+
// Server file will be added later by the setup-ssr generator
|
|
155
|
+
files.delete('server.ts');
|
|
156
|
+
browserTsConfigJson.files = Array.from(files);
|
|
157
|
+
browserTsConfigJson.compilerOptions ?? {};
|
|
158
|
+
browserTsConfigJson.compilerOptions.types = Array.from(new Set([
|
|
159
|
+
...(browserTsConfigJson.compilerOptions.types ?? []),
|
|
160
|
+
...(serverTsConfigJson.compilerOptions?.types ?? []),
|
|
161
|
+
]));
|
|
162
|
+
// Delete server tsconfig
|
|
163
|
+
tree.delete(serverTsConfigPath);
|
|
164
|
+
}
|
|
165
|
+
// Update project main tsconfig
|
|
166
|
+
const projectRootTsConfigPath = (0, posix_1.join)(project.root, 'tsconfig.json');
|
|
167
|
+
if (tree.exists(projectRootTsConfigPath)) {
|
|
168
|
+
const rootTsConfigJson = (0, devkit_1.readJson)(tree, projectRootTsConfigPath);
|
|
169
|
+
rootTsConfigJson.compilerOptions ?? {};
|
|
170
|
+
rootTsConfigJson.compilerOptions.esModuleInterop = true;
|
|
171
|
+
rootTsConfigJson.compilerOptions.downlevelIteration = undefined;
|
|
172
|
+
rootTsConfigJson.compilerOptions.allowSyntheticDefaultImports = undefined;
|
|
173
|
+
(0, devkit_1.writeJson)(tree, projectRootTsConfigPath, rootTsConfigJson);
|
|
174
|
+
}
|
|
175
|
+
// Update server file
|
|
176
|
+
const ssrMainFile = project.targets['server']?.options?.['main'];
|
|
177
|
+
if (typeof ssrMainFile === 'string') {
|
|
178
|
+
tree.delete(ssrMainFile);
|
|
179
|
+
// apply changes so the setup-ssr generator can access the updated project
|
|
180
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, project);
|
|
181
|
+
await (0, setup_ssr_1.setupSsr)(tree, { project: projectName, skipFormat: true });
|
|
182
|
+
// re-read project configuration as it might have changed
|
|
183
|
+
project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
184
|
+
}
|
|
185
|
+
// Delete all redundant targets
|
|
186
|
+
for (const [targetName, target] of Object.entries(project.targets)) {
|
|
187
|
+
if (redundantExecutors.has(target.executor)) {
|
|
188
|
+
delete project.targets[targetName];
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, project);
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
function getTargetsToConvert(targets) {
|
|
195
|
+
let buildTargetName;
|
|
196
|
+
let serverTargetName;
|
|
197
|
+
for (const target of Object.keys(targets)) {
|
|
198
|
+
if (targets[target].executor === '@nx/angular:application' ||
|
|
199
|
+
targets[target].executor === '@angular-devkit/build-angular:application') {
|
|
200
|
+
devkit_1.logger.warn('The project is already using the application builder. Skipping conversion.');
|
|
201
|
+
return {};
|
|
202
|
+
}
|
|
203
|
+
// build target
|
|
204
|
+
if (executorsToConvert.has(targets[target].executor)) {
|
|
205
|
+
for (const [, options] of (0, targets_1.allTargetOptions)(targets[target])) {
|
|
206
|
+
if (options.deployUrl) {
|
|
207
|
+
devkit_1.logger.warn(`The project is using the "deployUrl" option which is not available in the application builder. Skipping conversion.`);
|
|
208
|
+
return {};
|
|
209
|
+
}
|
|
210
|
+
if (options.customWebpackConfig) {
|
|
211
|
+
devkit_1.logger.warn(`The project is using a custom webpack configuration which is not supported by the esbuild-based application executor. Skipping conversion.`);
|
|
212
|
+
return {};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (buildTargetName) {
|
|
216
|
+
devkit_1.logger.warn('The project has more than one build target. Skipping conversion.');
|
|
217
|
+
return {};
|
|
218
|
+
}
|
|
219
|
+
buildTargetName = target;
|
|
220
|
+
}
|
|
221
|
+
// server target
|
|
222
|
+
if (serverTargetExecutors.has(targets[target].executor)) {
|
|
223
|
+
if (targets[target].executor === '@nx/angular:webpack-server') {
|
|
224
|
+
for (const [, options] of (0, targets_1.allTargetOptions)(targets[target])) {
|
|
225
|
+
if (options.customWebpackConfig) {
|
|
226
|
+
devkit_1.logger.warn(`The project is using a custom webpack configuration which is not supported by the esbuild-based application executor. Skipping conversion.`);
|
|
227
|
+
return {};
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (serverTargetName) {
|
|
232
|
+
devkit_1.logger.warn('The project has more than one server target. Skipping conversion.');
|
|
233
|
+
return {};
|
|
234
|
+
}
|
|
235
|
+
serverTargetName = target;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return { buildTargetName, serverTargetName };
|
|
239
|
+
}
|
|
240
|
+
exports.default = convertToApplicationExecutor;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "NxAngularConvertToApplicationExecutorGenerator",
|
|
4
|
+
"cli": "nx",
|
|
5
|
+
"title": "Converts projects to use the `@nx/angular:application` executor or the `@angular-devkit/build-angular:application` builder. _Note: this is only supported in Angular versions >= 17.0.0_.",
|
|
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
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"project": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "Name of the Angular application project to convert. It has to contain a target using one of the `@angular-devkit/build-angular:browser`, `@angular-devkit/build-angular:browser-esbuild`, `@nx/angular:browser` and `@nx/angular:browser-esbuild` executors. If not specified, all projects with such targets will be converted.",
|
|
12
|
+
"$default": {
|
|
13
|
+
"$source": "argv",
|
|
14
|
+
"index": 0
|
|
15
|
+
},
|
|
16
|
+
"x-priority": "important"
|
|
17
|
+
},
|
|
18
|
+
"skipFormat": {
|
|
19
|
+
"description": "Skip formatting files.",
|
|
20
|
+
"type": "boolean",
|
|
21
|
+
"default": false,
|
|
22
|
+
"x-priority": "internal"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"additionalProperties": false
|
|
26
|
+
}
|
|
@@ -13,15 +13,15 @@ export interface Schema {
|
|
|
13
13
|
export?: boolean;
|
|
14
14
|
skipFormat?: boolean;
|
|
15
15
|
/**
|
|
16
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx
|
|
16
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.
|
|
17
17
|
*/
|
|
18
18
|
flat?: boolean;
|
|
19
19
|
/**
|
|
20
|
-
* @deprecated Provide the `directory` option instead. It will be removed in Nx
|
|
20
|
+
* @deprecated Provide the `directory` option instead. It will be removed in Nx v19.
|
|
21
21
|
*/
|
|
22
22
|
path?: string;
|
|
23
23
|
/**
|
|
24
|
-
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx
|
|
24
|
+
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v19.
|
|
25
25
|
*/
|
|
26
26
|
project?: string;
|
|
27
27
|
}
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"$source": "projectName"
|
|
35
35
|
},
|
|
36
36
|
"x-dropdown": "projects",
|
|
37
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx
|
|
37
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19."
|
|
38
38
|
},
|
|
39
39
|
"prefix": {
|
|
40
40
|
"type": "string",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"type": "boolean",
|
|
75
75
|
"description": "When true (the default), creates the new files at the top level of the current project.",
|
|
76
76
|
"default": true,
|
|
77
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx
|
|
77
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19."
|
|
78
78
|
},
|
|
79
79
|
"module": {
|
|
80
80
|
"type": "string",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"$id": "NxMFHost",
|
|
4
4
|
"cli": "nx",
|
|
5
5
|
"title": "Nx Module Federation Host Application",
|
|
@@ -55,15 +55,15 @@
|
|
|
55
55
|
},
|
|
56
56
|
{
|
|
57
57
|
"value": "scss",
|
|
58
|
-
"label": "SASS(.scss) [
|
|
58
|
+
"label": "SASS(.scss) [ https://sass-lang.com ]"
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
61
|
"value": "sass",
|
|
62
|
-
"label": "SASS(.sass) [
|
|
62
|
+
"label": "SASS(.sass) [ https://sass-lang.com ]"
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
65
|
"value": "less",
|
|
66
|
-
"label": "LESS [
|
|
66
|
+
"label": "LESS [ https://lesscss.org ]"
|
|
67
67
|
}
|
|
68
68
|
]
|
|
69
69
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"$id": "NxAngularLibrarySecondaryEntryPoint",
|
|
4
4
|
"title": "Creates a secondary entry point for a library",
|
|
5
5
|
"description": "Creates a secondary entry point for an Angular publishable library.",
|
|
@@ -11,15 +11,15 @@ export interface Schema {
|
|
|
11
11
|
export?: boolean;
|
|
12
12
|
skipFormat?: boolean;
|
|
13
13
|
/**
|
|
14
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx
|
|
14
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.
|
|
15
15
|
*/
|
|
16
16
|
flat?: boolean;
|
|
17
17
|
/**
|
|
18
|
-
* @deprecated Provide the `directory` option instead. It will be removed in Nx
|
|
18
|
+
* @deprecated Provide the `directory` option instead. It will be removed in Nx v19.
|
|
19
19
|
*/
|
|
20
20
|
path?: string;
|
|
21
21
|
/**
|
|
22
|
-
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx
|
|
22
|
+
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v19.
|
|
23
23
|
*/
|
|
24
24
|
project?: string;
|
|
25
25
|
}
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
"$source": "projectName"
|
|
35
35
|
},
|
|
36
36
|
"x-dropdown": "projects",
|
|
37
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx
|
|
37
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19."
|
|
38
38
|
},
|
|
39
39
|
"flat": {
|
|
40
40
|
"type": "boolean",
|
|
41
41
|
"default": true,
|
|
42
42
|
"description": "When true (the default) creates files at the top level of the project.",
|
|
43
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx
|
|
43
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19."
|
|
44
44
|
},
|
|
45
45
|
"skipTests": {
|
|
46
46
|
"type": "boolean",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"$id": "NxMFRemote",
|
|
4
4
|
"cli": "nx",
|
|
5
5
|
"title": "Nx Module Federation Remote App",
|
|
@@ -55,15 +55,15 @@
|
|
|
55
55
|
},
|
|
56
56
|
{
|
|
57
57
|
"value": "scss",
|
|
58
|
-
"label": "SASS(.scss) [
|
|
58
|
+
"label": "SASS(.scss) [ https://sass-lang.com ]"
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
61
|
"value": "sass",
|
|
62
|
-
"label": "SASS(.sass) [
|
|
62
|
+
"label": "SASS(.sass) [ https://sass-lang.com ]"
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
65
|
"value": "less",
|
|
66
|
-
"label": "LESS [
|
|
66
|
+
"label": "LESS [ https://lesscss.org ]"
|
|
67
67
|
}
|
|
68
68
|
]
|
|
69
69
|
}
|
|
@@ -19,15 +19,15 @@ export interface Schema {
|
|
|
19
19
|
export?: boolean;
|
|
20
20
|
skipFormat?: boolean;
|
|
21
21
|
/**
|
|
22
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx
|
|
22
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.
|
|
23
23
|
*/
|
|
24
24
|
flat?: boolean;
|
|
25
25
|
/**
|
|
26
|
-
* @deprecated Provide the `directory` option instead. It will be removed in Nx
|
|
26
|
+
* @deprecated Provide the `directory` option instead. It will be removed in Nx v19.
|
|
27
27
|
*/
|
|
28
28
|
path?: string;
|
|
29
29
|
/**
|
|
30
|
-
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx
|
|
30
|
+
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v19.
|
|
31
31
|
*/
|
|
32
32
|
project?: string;
|
|
33
33
|
}
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"$source": "projectName"
|
|
41
41
|
},
|
|
42
42
|
"x-dropdown": "projects",
|
|
43
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx
|
|
43
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19."
|
|
44
44
|
},
|
|
45
45
|
"displayBlock": {
|
|
46
46
|
"description": "Specifies if the style will contain `:host { display: block; }`.",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"type": "boolean",
|
|
95
95
|
"description": "Create the new files at the top level of the current project.",
|
|
96
96
|
"default": false,
|
|
97
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx
|
|
97
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19."
|
|
98
98
|
},
|
|
99
99
|
"selector": {
|
|
100
100
|
"type": "string",
|
|
@@ -11,15 +11,15 @@ export interface Schema {
|
|
|
11
11
|
export?: boolean;
|
|
12
12
|
skipFormat?: boolean;
|
|
13
13
|
/**
|
|
14
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx
|
|
14
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.
|
|
15
15
|
*/
|
|
16
16
|
flat?: boolean;
|
|
17
17
|
/**
|
|
18
|
-
* @deprecated Provide the `directory` option instead. It will be removed in Nx
|
|
18
|
+
* @deprecated Provide the `directory` option instead. It will be removed in Nx v19.
|
|
19
19
|
*/
|
|
20
20
|
path?: string;
|
|
21
21
|
/**
|
|
22
|
-
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx
|
|
22
|
+
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v19.
|
|
23
23
|
*/
|
|
24
24
|
project?: string;
|
|
25
25
|
}
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"$source": "projectName"
|
|
42
42
|
},
|
|
43
43
|
"x-dropdown": "projects",
|
|
44
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx
|
|
44
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19."
|
|
45
45
|
},
|
|
46
46
|
"skipTests": {
|
|
47
47
|
"type": "boolean",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"type": "boolean",
|
|
59
59
|
"description": "Create the new files at the top level of the current project.",
|
|
60
60
|
"default": true,
|
|
61
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx
|
|
61
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19."
|
|
62
62
|
},
|
|
63
63
|
"selector": {
|
|
64
64
|
"type": "string",
|
|
@@ -9,15 +9,15 @@ export interface Schema {
|
|
|
9
9
|
export?: boolean;
|
|
10
10
|
skipFormat?: boolean;
|
|
11
11
|
/**
|
|
12
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx
|
|
12
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.
|
|
13
13
|
*/
|
|
14
14
|
flat?: boolean;
|
|
15
15
|
/**
|
|
16
|
-
* @deprecated Provide the `directory` option instead. It will be removed in Nx
|
|
16
|
+
* @deprecated Provide the `directory` option instead. It will be removed in Nx v19.
|
|
17
17
|
*/
|
|
18
18
|
path?: string;
|
|
19
19
|
/**
|
|
20
|
-
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx
|
|
20
|
+
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v19.
|
|
21
21
|
*/
|
|
22
22
|
project?: string;
|
|
23
23
|
}
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"$source": "projectName"
|
|
42
42
|
},
|
|
43
43
|
"x-dropdown": "projects",
|
|
44
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx
|
|
44
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19."
|
|
45
45
|
},
|
|
46
46
|
"skipTests": {
|
|
47
47
|
"type": "boolean",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"type": "boolean",
|
|
59
59
|
"description": "Create the new files at the top level of the current project.",
|
|
60
60
|
"default": true,
|
|
61
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx
|
|
61
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19."
|
|
62
62
|
},
|
|
63
63
|
"export": {
|
|
64
64
|
"type": "boolean",
|
|
@@ -2,23 +2,29 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addHydration = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const ast_utils_1 = require("../../../utils/nx-devkit/ast-utils");
|
|
6
|
-
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
7
5
|
const js_1 = require("@nx/js");
|
|
6
|
+
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
7
|
+
const ast_utils_1 = require("../../../utils/nx-devkit/ast-utils");
|
|
8
8
|
let tsModule;
|
|
9
|
+
let tsquery;
|
|
9
10
|
function addHydration(tree, options) {
|
|
10
11
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
11
12
|
if (!tsModule) {
|
|
12
13
|
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
14
|
+
tsquery = require('@phenomnomnominal/tsquery').tsquery;
|
|
13
15
|
}
|
|
14
|
-
const addImport = (source, symbolName, packageName, filePath, isDefault = false) => {
|
|
15
|
-
return (0, js_1.insertImport)(tree, source, filePath, symbolName, packageName, isDefault);
|
|
16
|
-
};
|
|
17
16
|
const pathToClientConfigFile = options.standalone
|
|
18
17
|
? (0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, 'app/app.config.ts')
|
|
19
18
|
: (0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, 'app/app.module.ts');
|
|
20
19
|
const sourceText = tree.read(pathToClientConfigFile, 'utf-8');
|
|
21
20
|
let sourceFile = tsModule.createSourceFile(pathToClientConfigFile, sourceText, tsModule.ScriptTarget.Latest, true);
|
|
21
|
+
const provideClientHydrationCallExpression = tsquery(sourceFile, 'ObjectLiteralExpression PropertyAssignment:has(Identifier[name=providers]) ArrayLiteralExpression CallExpression:has(Identifier[name=provideClientHydration])')[0];
|
|
22
|
+
if (provideClientHydrationCallExpression) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const addImport = (source, symbolName, packageName, filePath, isDefault = false) => {
|
|
26
|
+
return (0, js_1.insertImport)(tree, source, filePath, symbolName, packageName, isDefault);
|
|
27
|
+
};
|
|
22
28
|
sourceFile = addImport(sourceFile, 'provideClientHydration', '@angular/platform-browser', pathToClientConfigFile);
|
|
23
29
|
if (options.standalone) {
|
|
24
30
|
(0, ast_utils_1.addProviderToAppConfig)(tree, pathToClientConfigFile, 'provideClientHydration()');
|
|
@@ -46,7 +46,9 @@ function updateProjectConfigForBrowserBuilder(tree, schema) {
|
|
|
46
46
|
}
|
|
47
47
|
projectConfig.targets.server = {
|
|
48
48
|
dependsOn: ['build'],
|
|
49
|
-
executor: '@angular-devkit/build-angular:
|
|
49
|
+
executor: buildTarget.executor.startsWith('@angular-devkit/build-angular:')
|
|
50
|
+
? '@angular-devkit/build-angular:server'
|
|
51
|
+
: '@nx/angular:webpack-server',
|
|
50
52
|
options: {
|
|
51
53
|
outputPath: (0, devkit_1.joinPathFragments)(baseOutputPath, 'server'),
|
|
52
54
|
main: (0, devkit_1.joinPathFragments)(projectConfig.root, schema.serverFileName),
|
|
@@ -8,7 +8,8 @@ async function setupSsr(tree, schema) {
|
|
|
8
8
|
(0, lib_1.validateOptions)(tree, schema);
|
|
9
9
|
const options = (0, lib_1.normalizeOptions)(tree, schema);
|
|
10
10
|
const { targets } = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
11
|
-
const isUsingApplicationBuilder = targets.build.executor === '@angular-devkit/build-angular:application'
|
|
11
|
+
const isUsingApplicationBuilder = targets.build.executor === '@angular-devkit/build-angular:application' ||
|
|
12
|
+
targets.build.executor === '@nx/angular:application';
|
|
12
13
|
(0, lib_1.addDependencies)(tree, isUsingApplicationBuilder);
|
|
13
14
|
(0, lib_1.generateSSRFiles)(tree, options, isUsingApplicationBuilder);
|
|
14
15
|
if (!options.standalone) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"$id": "NxAngularStorybookStoriesGenerator",
|
|
4
4
|
"title": "Create Storybook stories/specs",
|
|
5
5
|
"description": "Creates Storybook stories/specs for all Angular components declared in a project.",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"$id": "NxAngularStorybookConfigurationGenerator",
|
|
4
4
|
"title": "Adds Storybook configuration to a project.",
|
|
5
5
|
"description": "Adds Storybook configuration to a project to be able to use and create stories.",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"configureCypress": {
|
|
30
30
|
"type": "boolean",
|
|
31
31
|
"description": "Specifies whether to configure Cypress or not.",
|
|
32
|
-
"x-deprecated": "Use interactionTests instead. This option will be removed in
|
|
32
|
+
"x-deprecated": "Use interactionTests instead. This option will be removed in v19."
|
|
33
33
|
},
|
|
34
34
|
"generateStories": {
|
|
35
35
|
"type": "boolean",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"generateCypressSpecs": {
|
|
42
42
|
"type": "boolean",
|
|
43
43
|
"description": "Specifies whether to automatically generate test files in the generated Cypress e2e app.",
|
|
44
|
-
"x-deprecated": "Use interactionTests instead. This option will be removed in
|
|
44
|
+
"x-deprecated": "Use interactionTests instead. This option will be removed in v19."
|
|
45
45
|
},
|
|
46
46
|
"configureStaticServe": {
|
|
47
47
|
"type": "boolean",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"cypressDirectory": {
|
|
54
54
|
"type": "string",
|
|
55
55
|
"description": "A directory where the Cypress project will be placed. Placed at the root by default.",
|
|
56
|
-
"x-deprecated": "Use interactionTests instead. This option will be removed in
|
|
56
|
+
"x-deprecated": "Use interactionTests instead. This option will be removed in v19."
|
|
57
57
|
},
|
|
58
58
|
"linter": {
|
|
59
59
|
"description": "The tool to use for running lint checks.",
|
|
@@ -6,7 +6,7 @@ const assert_compatible_storybook_version_1 = require("./lib/assert-compatible-s
|
|
|
6
6
|
const generate_stories_1 = require("./lib/generate-stories");
|
|
7
7
|
const generate_storybook_configuration_1 = require("./lib/generate-storybook-configuration");
|
|
8
8
|
const validate_options_1 = require("./lib/validate-options");
|
|
9
|
-
// TODO(katerina): Nx
|
|
9
|
+
// TODO(katerina): Nx 19 -> remove Cypress
|
|
10
10
|
async function storybookConfigurationGenerator(tree, options) {
|
|
11
11
|
(0, assert_compatible_storybook_version_1.assertCompatibleStorybookVersion)();
|
|
12
12
|
(0, validate_options_1.validateOptions)(options);
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const devkit_1 = require("@nx/devkit");
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const version_utils_1 = require("../../generators/utils/version-utils");
|
|
6
|
+
const targets_1 = require("../../utils/targets");
|
|
6
7
|
const projects_1 = require("../utils/projects");
|
|
7
8
|
const UNIVERSAL_PACKAGES = [
|
|
8
9
|
'@nguniversal/common',
|
|
@@ -38,7 +39,7 @@ async function default_1(tree) {
|
|
|
38
39
|
continue;
|
|
39
40
|
}
|
|
40
41
|
const outputPath = project.targets.build?.options?.outputPath;
|
|
41
|
-
for (const [, { main }] of allTargetOptions(target)) {
|
|
42
|
+
for (const [, { main }] of (0, targets_1.allTargetOptions)(target)) {
|
|
42
43
|
if (typeof main === 'string' &&
|
|
43
44
|
typeof outputPath === 'string' &&
|
|
44
45
|
tree.read(main, 'utf-8').includes('ngExpressEngine')) {
|
|
@@ -91,19 +92,6 @@ async function default_1(tree) {
|
|
|
91
92
|
await (0, devkit_1.formatFiles)(tree);
|
|
92
93
|
}
|
|
93
94
|
exports.default = default_1;
|
|
94
|
-
function* allTargetOptions(target) {
|
|
95
|
-
if (target.options) {
|
|
96
|
-
yield [undefined, target.options];
|
|
97
|
-
}
|
|
98
|
-
if (!target.configurations) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
for (const [name, options] of Object.entries(target.configurations)) {
|
|
102
|
-
if (options !== undefined) {
|
|
103
|
-
yield [name, options];
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
95
|
const TOKENS_FILE_CONTENT = `
|
|
108
96
|
import { InjectionToken } from '@angular/core';
|
|
109
97
|
import { Request, Response } from 'express';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.allTargetOptions = void 0;
|
|
4
|
+
function* allTargetOptions(target) {
|
|
5
|
+
if (target.options) {
|
|
6
|
+
yield [undefined, target.options];
|
|
7
|
+
}
|
|
8
|
+
if (!target.configurations) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
for (const [name, options] of Object.entries(target.configurations)) {
|
|
12
|
+
if (options !== undefined) {
|
|
13
|
+
yield [name, options];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.allTargetOptions = allTargetOptions;
|