@schematics/angular 19.0.0-next.1 → 19.0.0-next.3

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.
@@ -19,6 +19,6 @@ import { <% if(changeDetection !== 'Default') { %>ChangeDetectionStrategy, <% }%
19
19
  encapsulation: ViewEncapsulation.<%= viewEncapsulation %><% } if (changeDetection !== 'Default') { %>,
20
20
  changeDetection: ChangeDetectionStrategy.<%= changeDetection %><% } %>
21
21
  })
22
- export class <%= classify(name) %><%= classify(type) %> {
22
+ export <% if(exportDefault) {%>default <%}%>class <%= classify(name) %><%= classify(type) %> {
23
23
 
24
24
  }
@@ -14,6 +14,10 @@ export interface Schema {
14
14
  * The declaring NgModule exports this component.
15
15
  */
16
16
  export?: boolean;
17
+ /**
18
+ * Use default export for the component instead of a named export.
19
+ */
20
+ exportDefault?: boolean;
17
21
  /**
18
22
  * Create the new files at the top level of the current project.
19
23
  */
@@ -130,6 +130,11 @@
130
130
  "type": "boolean",
131
131
  "default": false,
132
132
  "description": "The declaring NgModule exports this component."
133
+ },
134
+ "exportDefault": {
135
+ "type": "boolean",
136
+ "default": false,
137
+ "description": "Use default export for the component instead of a named export."
133
138
  }
134
139
  },
135
140
  "required": ["name", "project"]
@@ -19,7 +19,6 @@ module.exports = function (config) {
19
19
  // for example, you can disable the random execution with `random: false`
20
20
  // or set a specific seed with `seed: 4321`
21
21
  },
22
- clearContext: false // leave Jasmine Spec Runner output visible in browser
23
22
  },
24
23
  jasmineHtmlReporter: {
25
24
  suppressAll: true // removes the duplicated traces
@@ -11,6 +11,11 @@
11
11
  "version": "19.0.0",
12
12
  "factory": "./update-workspace-config/migration",
13
13
  "description": "Update the workspace configuration by replacing deprecated options in 'angular.json' for compatibility with the latest Angular CLI changes."
14
+ },
15
+ "update-ssr-imports": {
16
+ "version": "19.0.0",
17
+ "factory": "./update-ssr-imports/migration",
18
+ "description": "Update '@angular/ssr' import paths to use the new '/node' entry point when 'CommonEngine' is detected."
14
19
  }
15
20
  }
16
21
  }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.dev/license
7
+ */
8
+ import { Rule } from '@angular-devkit/schematics';
9
+ /**
10
+ * Schematics rule that identifies and updates import declarations in TypeScript files.
11
+ * Specifically, it modifies imports of '@angular/ssr' by appending '/node' if the
12
+ * `CommonEngine` is used from the old entry point.
13
+ *
14
+ */
15
+ export default function (): Rule;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.dev/license
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || function (mod) {
26
+ if (mod && mod.__esModule) return mod;
27
+ var result = {};
28
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
+ __setModuleDefault(result, mod);
30
+ return result;
31
+ };
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ exports.default = default_1;
34
+ const ts = __importStar(require("../../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
35
+ function* visit(directory) {
36
+ for (const path of directory.subfiles) {
37
+ if (path.endsWith('.ts') && !path.endsWith('.d.ts')) {
38
+ const entry = directory.file(path);
39
+ if (entry) {
40
+ const content = entry.content;
41
+ if (content.includes('CommonEngine') && !content.includes('@angular/ssr/node')) {
42
+ const source = ts.createSourceFile(entry.path, content.toString().replace(/^\uFEFF/, ''), ts.ScriptTarget.Latest, true);
43
+ yield source;
44
+ }
45
+ }
46
+ }
47
+ }
48
+ for (const path of directory.subdirs) {
49
+ if (path === 'node_modules' || path.startsWith('.')) {
50
+ continue;
51
+ }
52
+ yield* visit(directory.dir(path));
53
+ }
54
+ }
55
+ /**
56
+ * Schematics rule that identifies and updates import declarations in TypeScript files.
57
+ * Specifically, it modifies imports of '@angular/ssr' by appending '/node' if the
58
+ * `CommonEngine` is used from the old entry point.
59
+ *
60
+ */
61
+ function default_1() {
62
+ return (tree) => {
63
+ for (const sourceFile of visit(tree.root)) {
64
+ let recorder;
65
+ const allImportDeclarations = sourceFile.statements.filter((n) => ts.isImportDeclaration(n));
66
+ if (allImportDeclarations.length === 0) {
67
+ continue;
68
+ }
69
+ const ssrImports = allImportDeclarations.filter((n) => ts.isStringLiteral(n.moduleSpecifier) && n.moduleSpecifier.text === '@angular/ssr');
70
+ for (const ssrImport of ssrImports) {
71
+ const ssrNamedBinding = getNamedImports(ssrImport);
72
+ if (ssrNamedBinding) {
73
+ const isUsingOldEntryPoint = ssrNamedBinding.elements.some((e) => e.name.text.startsWith('CommonEngine'));
74
+ if (!isUsingOldEntryPoint) {
75
+ continue;
76
+ }
77
+ recorder ??= tree.beginUpdate(sourceFile.fileName);
78
+ recorder.insertRight(ssrImport.moduleSpecifier.getEnd() - 1, '/node');
79
+ }
80
+ }
81
+ if (recorder) {
82
+ tree.commitUpdate(recorder);
83
+ }
84
+ }
85
+ };
86
+ }
87
+ function getNamedImports(importDeclaration) {
88
+ const namedBindings = importDeclaration?.importClause?.namedBindings;
89
+ if (namedBindings && ts.isNamedImports(namedBindings)) {
90
+ return namedBindings;
91
+ }
92
+ return undefined;
93
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematics/angular",
3
- "version": "19.0.0-next.1",
3
+ "version": "19.0.0-next.3",
4
4
  "description": "Schematics specific to Angular",
5
5
  "homepage": "https://github.com/angular/angular-cli",
6
6
  "keywords": [
@@ -22,8 +22,8 @@
22
22
  },
23
23
  "schematics": "./collection.json",
24
24
  "dependencies": {
25
- "@angular-devkit/core": "19.0.0-next.1",
26
- "@angular-devkit/schematics": "19.0.0-next.1",
25
+ "@angular-devkit/core": "19.0.0-next.3",
26
+ "@angular-devkit/schematics": "19.0.0-next.3",
27
27
  "jsonc-parser": "3.3.1"
28
28
  },
29
29
  "packageManager": "yarn@4.4.0",
package/server/index.js CHANGED
@@ -111,6 +111,10 @@ function addDependencies(skipInstall) {
111
111
  }
112
112
  const install = skipInstall ? utility_1.InstallBehavior.None : utility_1.InstallBehavior.Auto;
113
113
  return (0, schematics_1.chain)([
114
+ (0, utility_1.addDependency)('@angular/ssr', latest_versions_1.latestVersions.AngularSSR, {
115
+ type: utility_1.DependencyType.Default,
116
+ install,
117
+ }),
114
118
  (0, utility_1.addDependency)('@angular/platform-server', coreDep.version, {
115
119
  type: utility_1.DependencyType.Default,
116
120
  install,
@@ -123,7 +127,7 @@ function addDependencies(skipInstall) {
123
127
  };
124
128
  }
125
129
  function default_1(options) {
126
- return async (host, context) => {
130
+ return async (host) => {
127
131
  const workspace = await (0, workspace_1.getWorkspace)(host);
128
132
  const clientProject = workspace.projects.get(options.project);
129
133
  if (clientProject?.extensions.projectType !== 'application') {
@@ -1,5 +1,5 @@
1
1
  import { APP_BASE_HREF } from '@angular/common';
2
- import { CommonEngine } from '@angular/ssr';
2
+ import { CommonEngine } from '@angular/ssr/node';
3
3
  import express from 'express';
4
4
  import { fileURLToPath } from 'node:url';
5
5
  import { dirname, join, resolve } from 'node:path';
@@ -1,7 +1,7 @@
1
1
  import 'zone.js/node';
2
2
 
3
3
  import { APP_BASE_HREF } from '@angular/common';
4
- import { CommonEngine } from '@angular/ssr';
4
+ import { CommonEngine } from '@angular/ssr/node';
5
5
  import * as express from 'express';
6
6
  import { existsSync } from 'node:fs';
7
7
  import { join } from 'node:path';
package/ssr/index.js CHANGED
@@ -225,10 +225,6 @@ function updateWebpackBuilderServerTsConfigRule(options) {
225
225
  function addDependencies({ skipInstall }, isUsingApplicationBuilder) {
226
226
  const install = skipInstall ? utility_1.InstallBehavior.None : utility_1.InstallBehavior.Auto;
227
227
  const rules = [
228
- (0, utility_1.addDependency)('@angular/ssr', latest_versions_1.latestVersions.AngularSSR, {
229
- type: utility_1.DependencyType.Default,
230
- install,
231
- }),
232
228
  (0, utility_1.addDependency)('express', latest_versions_1.latestVersions['express'], {
233
229
  type: utility_1.DependencyType.Default,
234
230
  install,