@nx/angular 24.0.0-canary.20261019-c4bb923 → 24.0.0-canary.20261020-e7ffd79
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/dist/generators.d.ts +0 -4
- package/dist/generators.js +0 -4
- package/dist/ready-check.d.ts +1 -0
- package/dist/ready-check.js +8 -0
- package/dist/src/generators/application/lib/add-e2e.js +2 -0
- package/dist/src/generators/application/lib/add-serve-static-target.js +2 -0
- package/dist/src/generators/application/lib/create-project.js +2 -0
- package/dist/src/generators/convert-to-rspack/convert-to-rspack.js +6 -0
- package/dist/src/generators/ng-add/migrators/projects/app.migrator.d.ts +1 -0
- package/dist/src/generators/ng-add/migrators/projects/app.migrator.js +22 -0
- package/dist/src/generators/setup-ssr/files/v20+/application-builder/server/__serverFileName__ +15 -1
- package/dist/src/generators/setup-ssr/lib/add-dependencies.js +4 -0
- package/dist/src/generators/setup-ssr/lib/update-project-config.js +1 -0
- package/dist/src/generators/utils/testing.d.ts +4 -0
- package/dist/src/generators/utils/testing.js +19 -0
- package/dist/src/migrations/update-24-0-0/add-ready-when-signal.d.ts +4 -0
- package/dist/src/migrations/update-24-0-0/add-ready-when-signal.js +12 -0
- package/dist/src/migrations/update-24-0-0/add-ready-when-signal.md +59 -0
- package/dist/src/migrations/update-24-0-0/remove-scam-generator-defaults.d.ts +2 -0
- package/dist/src/migrations/update-24-0-0/remove-scam-generator-defaults.js +85 -0
- package/dist/src/migrations/update-24-0-0/remove-scam-generator-defaults.md +48 -0
- package/dist/src/plugins/plugin.js +3 -5
- package/dist/src/plugins/utils/dev-server-ready-check.d.ts +17 -0
- package/dist/src/plugins/utils/dev-server-ready-check.js +213 -0
- package/generators.json +0 -24
- package/migrations.json +12 -0
- package/package.json +13 -12
- package/dist/src/generators/scam/lib/convert-component-to-scam.d.ts +0 -3
- package/dist/src/generators/scam/lib/convert-component-to-scam.js +0 -41
- package/dist/src/generators/scam/lib/index.d.ts +0 -2
- package/dist/src/generators/scam/lib/index.js +0 -5
- package/dist/src/generators/scam/lib/normalize-options.d.ts +0 -3
- package/dist/src/generators/scam/lib/normalize-options.js +0 -34
- package/dist/src/generators/scam/scam.d.ts +0 -7
- package/dist/src/generators/scam/scam.js +0 -28
- package/dist/src/generators/scam/schema.d.ts +0 -30
- package/dist/src/generators/scam/schema.json +0 -126
- package/dist/src/generators/scam-directive/lib/convert-directive-to-scam.d.ts +0 -3
- package/dist/src/generators/scam-directive/lib/convert-directive-to-scam.js +0 -41
- package/dist/src/generators/scam-directive/lib/index.d.ts +0 -2
- package/dist/src/generators/scam-directive/lib/index.js +0 -5
- package/dist/src/generators/scam-directive/lib/normalize-options.d.ts +0 -3
- package/dist/src/generators/scam-directive/lib/normalize-options.js +0 -34
- package/dist/src/generators/scam-directive/scam-directive.d.ts +0 -7
- package/dist/src/generators/scam-directive/scam-directive.js +0 -28
- package/dist/src/generators/scam-directive/schema.d.ts +0 -23
- package/dist/src/generators/scam-directive/schema.json +0 -89
- package/dist/src/generators/scam-pipe/lib/convert-pipe-to-scam.d.ts +0 -3
- package/dist/src/generators/scam-pipe/lib/convert-pipe-to-scam.js +0 -41
- package/dist/src/generators/scam-pipe/lib/index.d.ts +0 -2
- package/dist/src/generators/scam-pipe/lib/index.js +0 -5
- package/dist/src/generators/scam-pipe/lib/normalize-options.d.ts +0 -3
- package/dist/src/generators/scam-pipe/lib/normalize-options.js +0 -36
- package/dist/src/generators/scam-pipe/scam-pipe.d.ts +0 -7
- package/dist/src/generators/scam-pipe/scam-pipe.js +0 -28
- package/dist/src/generators/scam-pipe/schema.d.ts +0 -21
- package/dist/src/generators/scam-pipe/schema.json +0 -67
- package/dist/src/generators/scam-to-standalone/lib/convert-scam-to-standalone.d.ts +0 -3
- package/dist/src/generators/scam-to-standalone/lib/convert-scam-to-standalone.js +0 -35
- package/dist/src/generators/scam-to-standalone/lib/get-component-data-from-ast.d.ts +0 -6
- package/dist/src/generators/scam-to-standalone/lib/get-component-data-from-ast.js +0 -15
- package/dist/src/generators/scam-to-standalone/lib/get-module-metadata-from-ast.d.ts +0 -9
- package/dist/src/generators/scam-to-standalone/lib/get-module-metadata-from-ast.js +0 -51
- package/dist/src/generators/scam-to-standalone/lib/get-target-project.d.ts +0 -2
- package/dist/src/generators/scam-to-standalone/lib/get-target-project.js +0 -13
- package/dist/src/generators/scam-to-standalone/lib/index.d.ts +0 -8
- package/dist/src/generators/scam-to-standalone/lib/index.js +0 -11
- package/dist/src/generators/scam-to-standalone/lib/replace-module-usages-with-component.d.ts +0 -2
- package/dist/src/generators/scam-to-standalone/lib/replace-module-usages-with-component.js +0 -20
- package/dist/src/generators/scam-to-standalone/lib/selector-exists-in-ast.d.ts +0 -2
- package/dist/src/generators/scam-to-standalone/lib/selector-exists-in-ast.js +0 -7
- package/dist/src/generators/scam-to-standalone/lib/verify-is-inline-scam.d.ts +0 -2
- package/dist/src/generators/scam-to-standalone/lib/verify-is-inline-scam.js +0 -10
- package/dist/src/generators/scam-to-standalone/lib/verify-module-is-scam.d.ts +0 -1
- package/dist/src/generators/scam-to-standalone/lib/verify-module-is-scam.js +0 -11
- package/dist/src/generators/scam-to-standalone/scam-to-standalone.d.ts +0 -7
- package/dist/src/generators/scam-to-standalone/scam-to-standalone.js +0 -31
- package/dist/src/generators/scam-to-standalone/schema.d.ts +0 -5
- package/dist/src/generators/scam-to-standalone/schema.json +0 -32
- package/dist/src/generators/utils/export-scam.d.ts +0 -11
- package/dist/src/generators/utils/export-scam.js +0 -35
package/dist/generators.d.ts
CHANGED
|
@@ -9,10 +9,6 @@ export * from './src/generators/library/library';
|
|
|
9
9
|
export * from './src/generators/ngrx-feature-store/ngrx-feature-store';
|
|
10
10
|
export * from './src/generators/ngrx-root-store/ngrx-root-store';
|
|
11
11
|
export * from './src/generators/pipe/pipe';
|
|
12
|
-
export * from './src/generators/scam-directive/scam-directive';
|
|
13
|
-
export * from './src/generators/scam-pipe/scam-pipe';
|
|
14
|
-
export * from './src/generators/scam-to-standalone/scam-to-standalone';
|
|
15
|
-
export * from './src/generators/scam/scam';
|
|
16
12
|
export * from './src/generators/setup-ssr/setup-ssr';
|
|
17
13
|
export * from './src/generators/stories/stories';
|
|
18
14
|
export * from './src/generators/storybook-configuration/storybook-configuration';
|
package/dist/generators.js
CHANGED
|
@@ -13,10 +13,6 @@ tslib_1.__exportStar(require("./src/generators/library/library"), exports);
|
|
|
13
13
|
tslib_1.__exportStar(require("./src/generators/ngrx-feature-store/ngrx-feature-store"), exports);
|
|
14
14
|
tslib_1.__exportStar(require("./src/generators/ngrx-root-store/ngrx-root-store"), exports);
|
|
15
15
|
tslib_1.__exportStar(require("./src/generators/pipe/pipe"), exports);
|
|
16
|
-
tslib_1.__exportStar(require("./src/generators/scam-directive/scam-directive"), exports);
|
|
17
|
-
tslib_1.__exportStar(require("./src/generators/scam-pipe/scam-pipe"), exports);
|
|
18
|
-
tslib_1.__exportStar(require("./src/generators/scam-to-standalone/scam-to-standalone"), exports);
|
|
19
|
-
tslib_1.__exportStar(require("./src/generators/scam/scam"), exports);
|
|
20
16
|
tslib_1.__exportStar(require("./src/generators/setup-ssr/setup-ssr"), exports);
|
|
21
17
|
tslib_1.__exportStar(require("./src/generators/stories/stories"), exports);
|
|
22
18
|
tslib_1.__exportStar(require("./src/generators/storybook-configuration/storybook-configuration"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function waitForDevServer(workspaceConfigPath: string): Promise<void>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.waitForDevServer = waitForDevServer;
|
|
4
|
+
const dev_server_ready_check_1 = require("./src/plugins/utils/dev-server-ready-check");
|
|
5
|
+
async function waitForDevServer(workspaceConfigPath) {
|
|
6
|
+
await (0, dev_server_ready_check_1.waitForAngularDevServer)(workspaceConfigPath);
|
|
7
|
+
process.exit(0);
|
|
8
|
+
}
|
|
@@ -53,6 +53,8 @@ async function addE2e(tree, options) {
|
|
|
53
53
|
enableTypedLinting: (0, internal_2.isTypedLintingEnabled)(options),
|
|
54
54
|
webServerCommand: e2eWebServerInfo.e2eWebServerCommand,
|
|
55
55
|
webServerAddress: e2eWebServerInfo.e2eWebServerAddress,
|
|
56
|
+
ciWebServerCommand: e2eWebServerInfo.e2eCiWebServerCommand,
|
|
57
|
+
ciWebServerAddress: e2eWebServerInfo.e2eCiBaseUrl,
|
|
56
58
|
rootProject: options.rootProject,
|
|
57
59
|
});
|
|
58
60
|
}
|
|
@@ -14,6 +14,8 @@ function addFileServerTarget(tree, options, targetName, e2ePort) {
|
|
|
14
14
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.name);
|
|
15
15
|
projectConfig.targets[targetName] = {
|
|
16
16
|
continuous: true,
|
|
17
|
+
readyWhen: { signal: true },
|
|
18
|
+
dependsOn: ['build'],
|
|
17
19
|
executor: '@nx/web:file-server',
|
|
18
20
|
options: {
|
|
19
21
|
buildTarget: `${options.name}:build`,
|
|
@@ -80,6 +80,7 @@ function createProjectForEsbuild(tree, options) {
|
|
|
80
80
|
},
|
|
81
81
|
serve: {
|
|
82
82
|
continuous: true,
|
|
83
|
+
readyWhen: { signal: true },
|
|
83
84
|
executor: '@angular/build:dev-server',
|
|
84
85
|
options: options.port ? { port: options.port } : undefined,
|
|
85
86
|
configurations: {
|
|
@@ -173,6 +174,7 @@ function createProjectForWebpack(tree, options) {
|
|
|
173
174
|
},
|
|
174
175
|
serve: {
|
|
175
176
|
continuous: true,
|
|
177
|
+
readyWhen: { signal: true },
|
|
176
178
|
executor: '@angular-devkit/build-angular:dev-server',
|
|
177
179
|
options: options.port ? { port: options.port } : undefined,
|
|
178
180
|
configurations: {
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.convertToRspack = convertToRspack;
|
|
4
4
|
const internal_1 = require("@nx/devkit/internal");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const node_util_1 = require("node:util");
|
|
6
7
|
const path_1 = require("path");
|
|
7
8
|
const posix_1 = require("path/posix");
|
|
8
9
|
const assert_supported_angular_version_1 = require("../../utils/assert-supported-angular-version");
|
|
@@ -490,6 +491,11 @@ async function convertToRspack(tree, schema) {
|
|
|
490
491
|
if (serveTarget.config.continuous) {
|
|
491
492
|
delete serveTarget.config.continuous;
|
|
492
493
|
}
|
|
494
|
+
// Nx writes it for the dev server builders, and it would override the
|
|
495
|
+
// readyWhen inferred for the Rspack serve target
|
|
496
|
+
if ((0, node_util_1.isDeepStrictEqual)(serveTarget.config.readyWhen, { signal: true })) {
|
|
497
|
+
delete serveTarget.config.readyWhen;
|
|
498
|
+
}
|
|
493
499
|
if (serveTarget.config.syncGenerators?.length === 1 &&
|
|
494
500
|
serveTarget.config.syncGenerators[0] === '@nx/js:typescript-sync') {
|
|
495
501
|
delete serveTarget.config.syncGenerators;
|
|
@@ -19,6 +19,7 @@ export declare class AppMigrator extends ProjectMigrator<SupportedTargets> {
|
|
|
19
19
|
private updatePrerenderTargetConfiguration;
|
|
20
20
|
private updateServerTargetConfiguration;
|
|
21
21
|
private updateServeSsrTargetConfiguration;
|
|
22
|
+
private updateDevServerTargets;
|
|
22
23
|
private updateTsConfigFileUsedByBuildTarget;
|
|
23
24
|
private updateTsConfigFileUsedByServerTarget;
|
|
24
25
|
}
|
|
@@ -50,6 +50,11 @@ const supportedTargets = {
|
|
|
50
50
|
],
|
|
51
51
|
},
|
|
52
52
|
};
|
|
53
|
+
const readySignalingServeBuilders = new Set([
|
|
54
|
+
'@angular/build:dev-server',
|
|
55
|
+
'@angular-devkit/build-angular:dev-server',
|
|
56
|
+
'@angular-devkit/build-angular:ssr-dev-server',
|
|
57
|
+
]);
|
|
53
58
|
// TODO(leo): this will replace `supportedTargets` once the full refactor is done.
|
|
54
59
|
const supportedBuilderMigrators = [
|
|
55
60
|
builders_1.AngularBuildUnitTestMigrator,
|
|
@@ -139,6 +144,7 @@ class AppMigrator extends project_migrator_1.ProjectMigrator {
|
|
|
139
144
|
this.updateServerTargetConfiguration();
|
|
140
145
|
this.updatePrerenderTargetConfiguration();
|
|
141
146
|
this.updateServeSsrTargetConfiguration();
|
|
147
|
+
this.updateDevServerTargets();
|
|
142
148
|
(0, devkit_1.updateProjectConfiguration)(this.tree, this.project.name, {
|
|
143
149
|
...this.projectConfig,
|
|
144
150
|
});
|
|
@@ -342,6 +348,22 @@ class AppMigrator extends project_migrator_1.ProjectMigrator {
|
|
|
342
348
|
}
|
|
343
349
|
});
|
|
344
350
|
}
|
|
351
|
+
updateDevServerTargets() {
|
|
352
|
+
for (const targetType of ['serve', 'serveSsr']) {
|
|
353
|
+
const targetName = this.targetNames[targetType];
|
|
354
|
+
if (!targetName || this.shouldSkipTargetTypeMigration(targetType)) {
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
const target = this.projectConfig.targets[targetName];
|
|
358
|
+
if (!readySignalingServeBuilders.has(target.executor)) {
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
target.continuous ??= true;
|
|
362
|
+
if (target.readyWhen === undefined) {
|
|
363
|
+
target.readyWhen = { signal: true };
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
345
367
|
updateTsConfigFileUsedByBuildTarget(rootTsConfigFile, projectOffsetFromRoot) {
|
|
346
368
|
if (!this.targetNames.build ||
|
|
347
369
|
this.shouldSkipTargetTypeMigration('build')) {
|
package/dist/src/generators/setup-ssr/files/v20+/application-builder/server/__serverFileName__
CHANGED
|
@@ -55,8 +55,22 @@ app.use('/**', (req, res, next) => {
|
|
|
55
55
|
*/
|
|
56
56
|
if (isMainModule(import.meta.url) || process.env['pm_id']) {
|
|
57
57
|
const port = process.env['PORT'] || <%= serverPort %>;
|
|
58
|
-
app.listen(port, () => {
|
|
58
|
+
const server = app.listen(port, async (error?: Error) => {
|
|
59
|
+
if (error) {
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
|
|
59
63
|
console.log(`Node Express server listening on http://localhost:${port}`);
|
|
64
|
+
// Set when Nx waits for this server to be ready
|
|
65
|
+
if (process.env['NX_READY_SIGNAL_SOCKET']) {
|
|
66
|
+
try {
|
|
67
|
+
// Function keeps TypeScript and bundlers from rewriting or bundling the import
|
|
68
|
+
const load = new Function('s', 'return import(s)') as (s: string) => Promise<{ emitReadySignal(server: unknown): boolean }>;
|
|
69
|
+
(await load('@nx/js/ready-signal')).emitReadySignal(server);
|
|
70
|
+
} catch {
|
|
71
|
+
// @nx/js isn't installed
|
|
72
|
+
}
|
|
73
|
+
}
|
|
60
74
|
});
|
|
61
75
|
}
|
|
62
76
|
|
|
@@ -20,6 +20,10 @@ function addDependencies(tree, options) {
|
|
|
20
20
|
// so ask for one that does rather than for whichever the range resolves to
|
|
21
21
|
dependencies['@angular/ssr'] =
|
|
22
22
|
(0, version_utils_1.withSsrAllowedHostsSupport)(angularDevkitVersion);
|
|
23
|
+
if (options.isUsingApplicationBuilder || options.isRspack) {
|
|
24
|
+
// The server template imports @nx/js/ready-signal, which must resolve from the workspace root
|
|
25
|
+
devDependencies['@nx/js'] = versions_1.nxVersion;
|
|
26
|
+
}
|
|
23
27
|
if (options.isUsingApplicationBuilder) {
|
|
24
28
|
dependencies['@angular-devkit/build-angular'] = angularDevkitVersion;
|
|
25
29
|
}
|
|
@@ -75,6 +75,7 @@ function updateProjectConfigForBrowserBuilder(tree, options) {
|
|
|
75
75
|
};
|
|
76
76
|
projectConfig.targets['serve-ssr'] = {
|
|
77
77
|
continuous: true,
|
|
78
|
+
readyWhen: { signal: true },
|
|
78
79
|
executor: '@angular-devkit/build-angular:ssr-dev-server',
|
|
79
80
|
configurations: {
|
|
80
81
|
development: {
|
|
@@ -4,3 +4,7 @@ import type { Schema as LibraryOptions } from '../library/schema';
|
|
|
4
4
|
export declare function generateTestApplication(tree: Tree, options: ApplicationOptions): Promise<void>;
|
|
5
5
|
export declare function generateTestLibrary(tree: Tree, options: LibraryOptions): Promise<void>;
|
|
6
6
|
export declare function createStorybookTestWorkspaceForLib(libName: string): Promise<Tree>;
|
|
7
|
+
export declare function generateTestInlineScam(tree: Tree, options: {
|
|
8
|
+
name: string;
|
|
9
|
+
path: string;
|
|
10
|
+
}): Promise<void>;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.generateTestApplication = generateTestApplication;
|
|
4
4
|
exports.generateTestLibrary = generateTestLibrary;
|
|
5
5
|
exports.createStorybookTestWorkspaceForLib = createStorybookTestWorkspaceForLib;
|
|
6
|
+
exports.generateTestInlineScam = generateTestInlineScam;
|
|
6
7
|
const devkit_1 = require("@nx/devkit");
|
|
7
8
|
const testing_1 = require("@nx/devkit/testing");
|
|
8
9
|
const internal_1 = require("@nx/js/internal");
|
|
@@ -211,6 +212,24 @@ export class StaticMemberDeclarationsModule {
|
|
|
211
212
|
});
|
|
212
213
|
return tree;
|
|
213
214
|
}
|
|
215
|
+
async function generateTestInlineScam(tree, options) {
|
|
216
|
+
await (0, component_1.componentGenerator)(tree, {
|
|
217
|
+
...options,
|
|
218
|
+
standalone: false,
|
|
219
|
+
skipImport: true,
|
|
220
|
+
skipFormat: true,
|
|
221
|
+
});
|
|
222
|
+
const { className } = (0, devkit_1.names)(options.name);
|
|
223
|
+
const componentFilePath = `${options.path}.ts`;
|
|
224
|
+
tree.write(componentFilePath, `import { NgModule } from '@angular/core';
|
|
225
|
+
${tree.read(componentFilePath, 'utf-8')}
|
|
226
|
+
@NgModule({
|
|
227
|
+
declarations: [${className}],
|
|
228
|
+
exports: [${className}],
|
|
229
|
+
})
|
|
230
|
+
export class ${className}Module {}
|
|
231
|
+
`);
|
|
232
|
+
}
|
|
214
233
|
function generateModule(tree, options) {
|
|
215
234
|
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
216
235
|
if (options.path === undefined) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = update;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
5
|
+
async function update(tree) {
|
|
6
|
+
return (0, internal_1.addReadyWhenSignalToTargets)(tree, [
|
|
7
|
+
'@angular/build:dev-server',
|
|
8
|
+
'@angular-devkit/build-angular:dev-server',
|
|
9
|
+
'@angular-devkit/build-angular:ssr-dev-server',
|
|
10
|
+
'@nx/angular:dev-server',
|
|
11
|
+
]);
|
|
12
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#### Report when Angular dev server targets are ready
|
|
2
|
+
|
|
3
|
+
Nx now knows when the Angular dev server builders are listening.
|
|
4
|
+
Nx listens for that report only on targets that set `readyWhen: { signal: true }`.
|
|
5
|
+
Tasks that depend on such a target with `waitFor: 'ready'` then start once the server is listening, instead of as soon as the target starts.
|
|
6
|
+
|
|
7
|
+
This migration sets `readyWhen: { signal: true }` on every target in your projects that uses one of these builders:
|
|
8
|
+
|
|
9
|
+
- `@angular/build:dev-server`
|
|
10
|
+
- `@angular-devkit/build-angular:dev-server`
|
|
11
|
+
- `@angular-devkit/build-angular:ssr-dev-server`
|
|
12
|
+
- `@nx/angular:dev-server`
|
|
13
|
+
|
|
14
|
+
A target without its own `executor` is updated too when a `targetDefaults` entry in `nx.json` gives it one of these builders.
|
|
15
|
+
|
|
16
|
+
The migration leaves a target unchanged in these cases:
|
|
17
|
+
|
|
18
|
+
- The target already sets `readyWhen`, including `null`.
|
|
19
|
+
- The target sets `continuous: false`, or sets no `continuous` and the `targetDefaults` entry that applies to it sets `continuous: false`. Nx only checks readiness for continuous targets.
|
|
20
|
+
- The `targetDefaults` entry that applies to the target sets `readyWhen`.
|
|
21
|
+
|
|
22
|
+
#### Sample code changes
|
|
23
|
+
|
|
24
|
+
##### Before
|
|
25
|
+
|
|
26
|
+
```json title="apps/app1/project.json"
|
|
27
|
+
{
|
|
28
|
+
// ...
|
|
29
|
+
"targets": {
|
|
30
|
+
"serve": {
|
|
31
|
+
"continuous": true,
|
|
32
|
+
"executor": "@angular/build:dev-server",
|
|
33
|
+
"options": {
|
|
34
|
+
"buildTarget": "app1:build"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
##### After
|
|
42
|
+
|
|
43
|
+
```json title="apps/app1/project.json" {10-12}
|
|
44
|
+
{
|
|
45
|
+
// ...
|
|
46
|
+
"targets": {
|
|
47
|
+
"serve": {
|
|
48
|
+
"continuous": true,
|
|
49
|
+
"executor": "@angular/build:dev-server",
|
|
50
|
+
"options": {
|
|
51
|
+
"buildTarget": "app1:build"
|
|
52
|
+
},
|
|
53
|
+
"readyWhen": {
|
|
54
|
+
"signal": true
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const COLLECTION = '@nx/angular';
|
|
6
|
+
const REMOVED_GENERATORS = [
|
|
7
|
+
'scam',
|
|
8
|
+
'scam-directive',
|
|
9
|
+
'scam-pipe',
|
|
10
|
+
'scam-to-standalone',
|
|
11
|
+
];
|
|
12
|
+
async function default_1(tree) {
|
|
13
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
14
|
+
if (nxJson && removeGeneratorDefaults(nxJson)) {
|
|
15
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
16
|
+
}
|
|
17
|
+
const angularJsonProjects = removeAngularJsonGeneratorDefaults(tree);
|
|
18
|
+
for (const [projectName, project] of (0, devkit_1.getProjects)(tree)) {
|
|
19
|
+
// updateProjectConfiguration can't write angular.json projects.
|
|
20
|
+
if (angularJsonProjects.has(projectName)) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (removeGeneratorDefaults(project)) {
|
|
24
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, project);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
28
|
+
return { skipAgentic: true };
|
|
29
|
+
}
|
|
30
|
+
function removeAngularJsonGeneratorDefaults(tree) {
|
|
31
|
+
if (!tree.exists('angular.json')) {
|
|
32
|
+
return new Set();
|
|
33
|
+
}
|
|
34
|
+
const angularJson = (0, devkit_1.readJson)(tree, 'angular.json');
|
|
35
|
+
const projects = isRecord(angularJson.projects)
|
|
36
|
+
? angularJson.projects
|
|
37
|
+
: {};
|
|
38
|
+
let changed = false;
|
|
39
|
+
for (const project of Object.values(projects)) {
|
|
40
|
+
if (!isRecord(project)) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
// The Angular CLI uses `schematics`, and Nx also reads `generators`.
|
|
44
|
+
for (const key of ['schematics', 'generators']) {
|
|
45
|
+
const config = { generators: project[key] };
|
|
46
|
+
if (removeGeneratorDefaults(config)) {
|
|
47
|
+
project[key] = config.generators;
|
|
48
|
+
changed = true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (changed) {
|
|
53
|
+
(0, devkit_1.writeJson)(tree, 'angular.json', angularJson);
|
|
54
|
+
}
|
|
55
|
+
return new Set(Object.keys(projects));
|
|
56
|
+
}
|
|
57
|
+
function removeGeneratorDefaults(config) {
|
|
58
|
+
const { generators } = config;
|
|
59
|
+
if (!isRecord(generators)) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
let changed = removeKeys(generators, REMOVED_GENERATORS.map((generator) => `${COLLECTION}:${generator}`));
|
|
63
|
+
const collection = generators[COLLECTION];
|
|
64
|
+
if (isRecord(collection) && removeKeys(collection, REMOVED_GENERATORS)) {
|
|
65
|
+
changed = true;
|
|
66
|
+
if (Object.keys(collection).length === 0) {
|
|
67
|
+
delete generators[COLLECTION];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (changed && Object.keys(generators).length === 0) {
|
|
71
|
+
// `delete` would keep the old value: updateProjectConfiguration merges into package.json `nx`.
|
|
72
|
+
config.generators = undefined;
|
|
73
|
+
}
|
|
74
|
+
return changed;
|
|
75
|
+
}
|
|
76
|
+
function removeKeys(obj, keys) {
|
|
77
|
+
const presentKeys = keys.filter((key) => key in obj);
|
|
78
|
+
for (const key of presentKeys) {
|
|
79
|
+
delete obj[key];
|
|
80
|
+
}
|
|
81
|
+
return presentKeys.length > 0;
|
|
82
|
+
}
|
|
83
|
+
function isRecord(value) {
|
|
84
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
85
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#### Remove defaults for the removed SCAM generators
|
|
2
|
+
|
|
3
|
+
Nx v24 removes the generators that created and converted single component Angular modules (SCAMs):
|
|
4
|
+
|
|
5
|
+
- `@nx/angular:scam`
|
|
6
|
+
- `@nx/angular:scam-directive`
|
|
7
|
+
- `@nx/angular:scam-pipe`
|
|
8
|
+
- `@nx/angular:scam-to-standalone`
|
|
9
|
+
|
|
10
|
+
Nx no longer reads generator defaults set for them.
|
|
11
|
+
This migration removes those defaults from `nx.json` and from the configuration of every project, including projects defined in `angular.json`.
|
|
12
|
+
It handles both the `"@nx/angular:scam"` key form and the nested `"@nx/angular": { "scam": {} }` form.
|
|
13
|
+
When the removal leaves the `@nx/angular` entry or the whole `generators` object (`schematics` in `angular.json`) empty, the migration removes it too.
|
|
14
|
+
|
|
15
|
+
The migration doesn't change commands or scripts that run these generators.
|
|
16
|
+
Use the `@nx/angular:component`, `@nx/angular:directive`, or `@nx/angular:pipe` generators instead.
|
|
17
|
+
|
|
18
|
+
#### Sample code changes
|
|
19
|
+
|
|
20
|
+
##### Before
|
|
21
|
+
|
|
22
|
+
```json title="nx.json"
|
|
23
|
+
{
|
|
24
|
+
"generators": {
|
|
25
|
+
"@nx/angular:component": {
|
|
26
|
+
"type": "component"
|
|
27
|
+
},
|
|
28
|
+
"@nx/angular:scam": {
|
|
29
|
+
"type": "component"
|
|
30
|
+
},
|
|
31
|
+
"@nx/angular:scam-directive": {
|
|
32
|
+
"type": "directive"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
##### After
|
|
39
|
+
|
|
40
|
+
```json title="nx.json"
|
|
41
|
+
{
|
|
42
|
+
"generators": {
|
|
43
|
+
"@nx/angular:component": {
|
|
44
|
+
"type": "component"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
@@ -138,8 +138,10 @@ async function buildAngularProjects(configFilePath, options, angularWorkspaceRoo
|
|
|
138
138
|
else if (knownExecutors.build.has(angularTarget.builder)) {
|
|
139
139
|
await updateBuildTarget(projectName, nxTargetName, targets[nxTargetName], angularTarget, context, angularWorkspaceRoot, project.root, namedInputs);
|
|
140
140
|
}
|
|
141
|
-
else if (knownExecutors.devServer.has(angularTarget.builder)
|
|
141
|
+
else if (knownExecutors.devServer.has(angularTarget.builder) ||
|
|
142
|
+
knownExecutors.serveSsr.has(angularTarget.builder)) {
|
|
142
143
|
targets[nxTargetName].continuous = true;
|
|
144
|
+
targets[nxTargetName].readyWhen = (0, internal_1.getReadyCheckReadyWhen)('@nx/angular/ready-check', (0, node_path_1.basename)(configFilePath));
|
|
143
145
|
targets[nxTargetName].metadata.help.example.options = { port: 4201 };
|
|
144
146
|
}
|
|
145
147
|
else if (knownExecutors.extractI18n.has(angularTarget.builder)) {
|
|
@@ -153,10 +155,6 @@ async function buildAngularProjects(configFilePath, options, angularWorkspaceRoo
|
|
|
153
155
|
else if (knownExecutors.server.has(angularTarget.builder)) {
|
|
154
156
|
updateServerTarget(targets[nxTargetName], angularTarget, context, angularWorkspaceRoot, project.root, namedInputs);
|
|
155
157
|
}
|
|
156
|
-
else if (knownExecutors.serveSsr.has(angularTarget.builder)) {
|
|
157
|
-
targets[nxTargetName].continuous = true;
|
|
158
|
-
targets[nxTargetName].metadata.help.example.options = { port: 4201 };
|
|
159
|
-
}
|
|
160
158
|
else if (knownExecutors.prerender.has(angularTarget.builder)) {
|
|
161
159
|
prerenderTargets.push({ target: nxTargetName, project: projectName });
|
|
162
160
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ServerAddress } from '@nx/devkit/internal';
|
|
2
|
+
import type { AngularProjectConfiguration } from '../plugin';
|
|
3
|
+
export interface AngularWorkspace {
|
|
4
|
+
projects?: Record<string, AngularProjectConfiguration>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Where the dev server of the task's `ng serve` or `ng run` command listens,
|
|
8
|
+
* resolved the way the Angular CLI and the target's builder resolve it, or
|
|
9
|
+
* null when nothing can be probed.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getDevServerAddress(options: Record<string, unknown>, workspace: AngularWorkspace, root: string): ServerAddress | null;
|
|
12
|
+
/**
|
|
13
|
+
* The readyWhen of the inferred dev server targets. Runs in the env and with
|
|
14
|
+
* the options of the task, resolves the target its `ng` command runs from the
|
|
15
|
+
* workspace config, and waits for the dev server's port.
|
|
16
|
+
*/
|
|
17
|
+
export declare function waitForAngularDevServer(workspaceConfigPath: string): Promise<void>;
|