@schematics/angular 19.0.0-next.9 → 19.0.0-rc.0

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.
Files changed (51) hide show
  1. package/app-shell/index.js +71 -74
  2. package/app-shell/schema.d.ts +4 -0
  3. package/app-shell/schema.json +5 -0
  4. package/application/files/module-files/src/app/app.component.spec.ts.template +4 -2
  5. package/application/files/module-files/src/app/app.component.ts.template +2 -1
  6. package/application/files/module-files/src/app/app.module.ts.template +2 -2
  7. package/application/files/module-files/src/main.ts.template +1 -2
  8. package/application/files/standalone-files/src/app/app.component.spec.ts.template +4 -2
  9. package/application/files/standalone-files/src/app/app.component.ts.template +0 -1
  10. package/application/files/standalone-files/src/app/app.config.ts.template +2 -2
  11. package/application/index.js +3 -2
  12. package/application/schema.d.ts +9 -0
  13. package/application/schema.json +9 -0
  14. package/collection.json +2 -2
  15. package/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.ts.template +3 -2
  16. package/component/index.js +1 -0
  17. package/config/files/.browserslistrc.template +1 -0
  18. package/directive/files/__name@dasherize@if-flat__/__name@dasherize__.directive.ts.template +2 -2
  19. package/directive/index.js +1 -0
  20. package/library/files/README.md.template +49 -10
  21. package/ng-new/index.js +2 -0
  22. package/ng-new/schema.d.ts +9 -0
  23. package/ng-new/schema.json +9 -0
  24. package/package.json +3 -3
  25. package/pipe/files/__name@dasherize@if-flat__/__name@dasherize__.pipe.ts.template +2 -2
  26. package/server/files/application-builder/ngmodule-src/app/app.module.server.ts.template +13 -0
  27. package/server/files/application-builder/ngmodule-src/app/app.routes.server.ts.template +8 -0
  28. package/server/files/application-builder/standalone-src/app/app.config.server.ts.template +14 -0
  29. package/server/files/application-builder/standalone-src/app/app.routes.server.ts.template +8 -0
  30. package/server/files/server-builder/ngmodule-src/main.server.ts.template +1 -0
  31. package/server/files/server-builder/standalone-src/main.server.ts.template +7 -0
  32. package/server/index.js +16 -6
  33. package/server/schema.d.ts +5 -0
  34. package/server/schema.json +4 -0
  35. package/service-worker/files/ngsw-config.json.template +1 -0
  36. package/ssr/files/application-builder/server.ts.template +57 -42
  37. package/ssr/files/application-builder-common-engine/server.ts.template +65 -0
  38. package/ssr/files/server-builder/server.ts.template +1 -1
  39. package/ssr/index.js +20 -18
  40. package/ssr/schema.d.ts +5 -0
  41. package/ssr/schema.json +6 -0
  42. package/utility/latest-versions/package.json +1 -1
  43. package/utility/latest-versions.js +2 -2
  44. package/utility/workspace-models.d.ts +1 -1
  45. package/utility/workspace-models.js +1 -1
  46. package/workspace/files/README.md.template +41 -9
  47. /package/server/files/{src → application-builder/ngmodule-src}/main.server.ts.template +0 -0
  48. /package/server/files/{standalone-src → application-builder/standalone-src}/main.server.ts.template +0 -0
  49. /package/server/files/{src → server-builder/ngmodule-src}/app/app.module.server.ts.template +0 -0
  50. /package/server/files/{root → server-builder/root}/tsconfig.server.json.template +0 -0
  51. /package/server/files/{standalone-src → server-builder/standalone-src}/app/app.config.server.ts.template +0 -0
@@ -106,59 +106,6 @@ function validateProject(mainPath) {
106
106
  }
107
107
  };
108
108
  }
109
- function addAppShellConfigToWorkspace(options) {
110
- return (host, context) => {
111
- return (0, workspace_1.updateWorkspace)((workspace) => {
112
- const project = workspace.projects.get(options.project);
113
- if (!project) {
114
- return;
115
- }
116
- const buildTarget = project.targets.get('build');
117
- if (buildTarget?.builder === workspace_models_1.Builders.Application) {
118
- // Application builder configuration.
119
- const prodConfig = buildTarget.configurations?.production;
120
- if (!prodConfig) {
121
- throw new schematics_1.SchematicsException(`A "production" configuration is not defined for the "build" builder.`);
122
- }
123
- prodConfig.appShell = true;
124
- return;
125
- }
126
- // Webpack based builders configuration.
127
- // Validation of targets is handled already in the main function.
128
- // Duplicate keys means that we have configurations in both server and build builders.
129
- const serverConfigKeys = project.targets.get('server')?.configurations ?? {};
130
- const buildConfigKeys = project.targets.get('build')?.configurations ?? {};
131
- const configurationNames = Object.keys({
132
- ...serverConfigKeys,
133
- ...buildConfigKeys,
134
- });
135
- const configurations = {};
136
- for (const key of configurationNames) {
137
- if (!serverConfigKeys[key]) {
138
- context.logger.warn(`Skipped adding "${key}" configuration to "app-shell" target as it's missing from "server" target.`);
139
- continue;
140
- }
141
- if (!buildConfigKeys[key]) {
142
- context.logger.warn(`Skipped adding "${key}" configuration to "app-shell" target as it's missing from "build" target.`);
143
- continue;
144
- }
145
- configurations[key] = {
146
- browserTarget: `${options.project}:build:${key}`,
147
- serverTarget: `${options.project}:server:${key}`,
148
- };
149
- }
150
- project.targets.add({
151
- name: 'app-shell',
152
- builder: workspace_models_1.Builders.AppShell,
153
- defaultConfiguration: configurations['production'] ? 'production' : undefined,
154
- options: {
155
- route: APP_SHELL_ROUTE,
156
- },
157
- configurations,
158
- });
159
- });
160
- };
161
- }
162
109
  function addRouterModule(mainPath) {
163
110
  return (host) => {
164
111
  const modulePath = (0, ng_ast_utils_1.getAppModulePath)(host, mainPath);
@@ -184,6 +131,24 @@ function getMetadataProperty(metadata, propertyName) {
184
131
  })[0];
185
132
  return property;
186
133
  }
134
+ function addAppShellConfigToWorkspace(options) {
135
+ return (0, workspace_1.updateWorkspace)((workspace) => {
136
+ const project = workspace.projects.get(options.project);
137
+ if (!project) {
138
+ return;
139
+ }
140
+ const buildTarget = project.targets.get('build');
141
+ if (buildTarget?.builder === workspace_models_1.Builders.Application ||
142
+ buildTarget?.builder === workspace_models_1.Builders.BuildApplication) {
143
+ // Application builder configuration.
144
+ const prodConfig = buildTarget.configurations?.production;
145
+ if (!prodConfig) {
146
+ throw new schematics_1.SchematicsException(`A "production" configuration is not defined for the "build" builder.`);
147
+ }
148
+ prodConfig.appShell = true;
149
+ }
150
+ });
151
+ }
187
152
  function addServerRoutes(options) {
188
153
  return async (host) => {
189
154
  // The workspace gets updated so this needs to be reloaded
@@ -237,13 +202,12 @@ function addStandaloneServerRoute(options) {
237
202
  if (!host.exists(configFilePath)) {
238
203
  throw new schematics_1.SchematicsException(`Cannot find "${configFilePath}".`);
239
204
  }
205
+ const recorder = host.beginUpdate(configFilePath);
240
206
  let configSourceFile = getSourceFile(host, configFilePath);
241
207
  if (!(0, ast_utils_1.isImported)(configSourceFile, 'ROUTES', '@angular/router')) {
242
208
  const routesChange = (0, ast_utils_1.insertImport)(configSourceFile, configFilePath, 'ROUTES', '@angular/router');
243
- const recorder = host.beginUpdate(configFilePath);
244
209
  if (routesChange) {
245
210
  (0, change_1.applyToUpdateRecorder)(recorder, [routesChange]);
246
- host.commitUpdate(recorder);
247
211
  }
248
212
  }
249
213
  configSourceFile = getSourceFile(host, configFilePath);
@@ -252,29 +216,59 @@ function addStandaloneServerRoute(options) {
252
216
  throw new schematics_1.SchematicsException(`Cannot find the "providers" configuration in "${configFilePath}".`);
253
217
  }
254
218
  // Add route to providers literal.
255
- const newProvidersLiteral = typescript_1.default.factory.updateArrayLiteralExpression(providersLiteral, [
256
- ...providersLiteral.elements,
257
- typescript_1.default.factory.createObjectLiteralExpression([
258
- typescript_1.default.factory.createPropertyAssignment('provide', typescript_1.default.factory.createIdentifier('ROUTES')),
259
- typescript_1.default.factory.createPropertyAssignment('multi', typescript_1.default.factory.createIdentifier('true')),
260
- typescript_1.default.factory.createPropertyAssignment('useValue', typescript_1.default.factory.createArrayLiteralExpression([
261
- typescript_1.default.factory.createObjectLiteralExpression([
262
- typescript_1.default.factory.createPropertyAssignment('path', typescript_1.default.factory.createIdentifier(`'${APP_SHELL_ROUTE}'`)),
263
- typescript_1.default.factory.createPropertyAssignment('component', typescript_1.default.factory.createIdentifier('AppShellComponent')),
264
- ], true),
265
- ], true)),
266
- ], true),
267
- ]);
268
- const recorder = host.beginUpdate(configFilePath);
269
219
  recorder.remove(providersLiteral.getStart(), providersLiteral.getWidth());
270
- const printer = typescript_1.default.createPrinter();
271
- recorder.insertRight(providersLiteral.getStart(), printer.printNode(typescript_1.default.EmitHint.Unspecified, newProvidersLiteral, configSourceFile));
220
+ const updatedProvidersString = [
221
+ ...providersLiteral.elements.map((element) => ' ' + element.getText()),
222
+ ` {
223
+ provide: ROUTES,
224
+ multi: true,
225
+ useValue: [{
226
+ path: '${APP_SHELL_ROUTE}',
227
+ component: AppShellComponent
228
+ }]
229
+ }\n `,
230
+ ];
231
+ recorder.insertRight(providersLiteral.getStart(), `[\n${updatedProvidersString.join(',\n')}]`);
272
232
  // Add AppShellComponent import
273
233
  const appShellImportChange = (0, ast_utils_1.insertImport)(configSourceFile, configFilePath, 'AppShellComponent', './app-shell/app-shell.component');
274
234
  (0, change_1.applyToUpdateRecorder)(recorder, [appShellImportChange]);
275
235
  host.commitUpdate(recorder);
276
236
  };
277
237
  }
238
+ function addServerRoutingConfig(options) {
239
+ return async (host) => {
240
+ const workspace = await (0, workspace_1.getWorkspace)(host);
241
+ const project = workspace.projects.get(options.project);
242
+ if (!project) {
243
+ throw new schematics_1.SchematicsException(`Project name "${options.project}" doesn't not exist.`);
244
+ }
245
+ const configFilePath = (0, posix_1.join)(project.sourceRoot ?? 'src', 'app/app.routes.server.ts');
246
+ if (!host.exists(configFilePath)) {
247
+ throw new schematics_1.SchematicsException(`Cannot find "${configFilePath}".`);
248
+ }
249
+ const sourceFile = getSourceFile(host, configFilePath);
250
+ const nodes = (0, ast_utils_1.getSourceNodes)(sourceFile);
251
+ // Find the serverRoutes variable declaration
252
+ const serverRoutesNode = nodes.find((node) => typescript_1.default.isVariableDeclaration(node) &&
253
+ node.initializer &&
254
+ typescript_1.default.isArrayLiteralExpression(node.initializer) &&
255
+ node.type &&
256
+ typescript_1.default.isArrayTypeNode(node.type) &&
257
+ node.type.getText().includes('ServerRoute'));
258
+ if (!serverRoutesNode) {
259
+ throw new schematics_1.SchematicsException(`Cannot find the "ServerRoute" configuration in "${configFilePath}".`);
260
+ }
261
+ const recorder = host.beginUpdate(configFilePath);
262
+ const arrayLiteral = serverRoutesNode.initializer;
263
+ const firstElementPosition = arrayLiteral.elements[0]?.getStart() ?? arrayLiteral.getStart() + 1;
264
+ const newRouteString = `{
265
+ path: '${APP_SHELL_ROUTE}',
266
+ renderMode: RenderMode.AppShell
267
+ },\n`;
268
+ recorder.insertLeft(firstElementPosition, newRouteString);
269
+ host.commitUpdate(recorder);
270
+ };
271
+ }
278
272
  function default_1(options) {
279
273
  return async (tree) => {
280
274
  const browserEntryPoint = await (0, util_1.getMainFilePath)(tree, options.project);
@@ -282,9 +276,12 @@ function default_1(options) {
282
276
  return (0, schematics_1.chain)([
283
277
  validateProject(browserEntryPoint),
284
278
  (0, schematics_1.schematic)('server', options),
285
- addAppShellConfigToWorkspace(options),
286
- isStandalone ? (0, schematics_1.noop)() : addRouterModule(browserEntryPoint),
287
- isStandalone ? addStandaloneServerRoute(options) : addServerRoutes(options),
279
+ ...(isStandalone
280
+ ? [addStandaloneServerRoute(options)]
281
+ : [addRouterModule(browserEntryPoint), addServerRoutes(options)]),
282
+ options.serverRouting
283
+ ? addServerRoutingConfig(options)
284
+ : addAppShellConfigToWorkspace(options),
288
285
  (0, schematics_1.schematic)('component', {
289
286
  name: 'app-shell',
290
287
  module: 'app.module.server.ts',
@@ -6,4 +6,8 @@ export interface Schema {
6
6
  * The name of the related client app.
7
7
  */
8
8
  project: string;
9
+ /**
10
+ * Creates a server application using the Server Routing API (Developer Preview).
11
+ */
12
+ serverRouting?: boolean;
9
13
  }
@@ -12,6 +12,11 @@
12
12
  "$default": {
13
13
  "$source": "projectName"
14
14
  }
15
+ },
16
+ "serverRouting": {
17
+ "description": "Creates a server application using the Server Routing API (Developer Preview).",
18
+ "type": "boolean",
19
+ "default": false
15
20
  }
16
21
  },
17
22
  "required": ["project"]
@@ -1,4 +1,5 @@
1
- import { TestBed } from '@angular/core/testing';<% if (routing) { %>
1
+ <% if(experimentalZoneless) { %>import { provideExperimentalZonelessChangeDetection } from '@angular/core';
2
+ <% } %>import { TestBed } from '@angular/core/testing';<% if (routing) { %>
2
3
  import { RouterModule } from '@angular/router';<% } %>
3
4
  import { AppComponent } from './app.component';
4
5
 
@@ -10,7 +11,8 @@ describe('AppComponent', () => {
10
11
  ],<% } %>
11
12
  declarations: [
12
13
  AppComponent
13
- ],
14
+ ],<% if(experimentalZoneless) { %>
15
+ providers: [provideExperimentalZonelessChangeDetection()]<% } %>
14
16
  }).compileComponents();
15
17
  });
16
18
 
@@ -9,7 +9,8 @@ import { Component } from '@angular/core';
9
9
  %><router-outlet /><%
10
10
  } %>
11
11
  `,<% } else { %>
12
- templateUrl: './app.component.html',<% } if(inlineStyle) { %>
12
+ templateUrl: './app.component.html',<% } %>
13
+ standalone: false,<% if(inlineStyle) { %>
13
14
  styles: []<% } else { %>
14
15
  styleUrl: './app.component.<%= style %>'<% } %>
15
16
  })
@@ -1,4 +1,4 @@
1
- import { NgModule } from '@angular/core';
1
+ import { NgModule<% if(experimentalZoneless) { %>, provideExperimentalZonelessChangeDetection<% } %> } from '@angular/core';
2
2
  import { BrowserModule } from '@angular/platform-browser';
3
3
  <% if (routing) { %>
4
4
  import { AppRoutingModule } from './app-routing.module';<% } %>
@@ -12,7 +12,7 @@ import { AppComponent } from './app.component';
12
12
  BrowserModule<% if (routing) { %>,
13
13
  AppRoutingModule<% } %>
14
14
  ],
15
- providers: [],
15
+ providers: [<% if (experimentalZoneless) { %>provideExperimentalZonelessChangeDetection()<% } %>],
16
16
  bootstrap: [AppComponent]
17
17
  })
18
18
  export class AppModule { }
@@ -1,10 +1,9 @@
1
1
  <% if(!!viewEncapsulation) { %>import { ViewEncapsulation } from '@angular/core';
2
2
  <% }%>import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3
-
4
3
  import { AppModule } from './app/app.module';
5
4
 
6
5
  platformBrowserDynamic().bootstrapModule(AppModule, {
7
- ngZoneEventCoalescing: true<% if(!!viewEncapsulation) { %>,
6
+ <% if(!experimentalZoneless) { %>ngZoneEventCoalescing: true,<% } %><% if(!!viewEncapsulation) { %>
8
7
  defaultEncapsulation: ViewEncapsulation.<%= viewEncapsulation %><% } %>
9
8
  })
10
9
  .catch(err => console.error(err));
@@ -1,10 +1,12 @@
1
- import { TestBed } from '@angular/core/testing';
1
+ <% if(experimentalZoneless) { %>import { provideExperimentalZonelessChangeDetection } from '@angular/core';
2
+ <% } %>import { TestBed } from '@angular/core/testing';
2
3
  import { AppComponent } from './app.component';
3
4
 
4
5
  describe('AppComponent', () => {
5
6
  beforeEach(async () => {
6
7
  await TestBed.configureTestingModule({
7
- imports: [AppComponent],
8
+ imports: [AppComponent],<% if(experimentalZoneless) { %>
9
+ providers: [provideExperimentalZonelessChangeDetection()]<% } %>
8
10
  }).compileComponents();
9
11
  });
10
12
 
@@ -3,7 +3,6 @@ import { RouterOutlet } from '@angular/router';<% } %>
3
3
 
4
4
  @Component({
5
5
  selector: '<%= selector %>',
6
- standalone: true,
7
6
  imports: [<% if(routing) { %>RouterOutlet<% } %>],<% if(inlineTemplate) { %>
8
7
  template: `
9
8
  <h1>Welcome to {{title}}!</h1>
@@ -1,8 +1,8 @@
1
- import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';<% if (routing) { %>
1
+ import { ApplicationConfig, <% if(!experimentalZoneless) { %>provideZoneChangeDetection<% } else { %>provideExperimentalZonelessChangeDetection<% } %> } from '@angular/core';<% if (routing) { %>
2
2
  import { provideRouter } from '@angular/router';
3
3
 
4
4
  import { routes } from './app.routes';<% } %>
5
5
 
6
6
  export const appConfig: ApplicationConfig = {
7
- providers: [provideZoneChangeDetection({ eventCoalescing: true })<% if (routing) { %>, provideRouter(routes)<% } %>]
7
+ providers: [<% if(experimentalZoneless) { %>provideExperimentalZonelessChangeDetection()<% } else { %>provideZoneChangeDetection({ eventCoalescing: true })<% } %><% if (routing) {%>, provideRouter(routes)<% } %>]
8
8
  };
@@ -78,6 +78,7 @@ function default_1(options) {
78
78
  options.ssr
79
79
  ? (0, schematics_1.schematic)('ssr', {
80
80
  project: options.name,
81
+ serverRouting: options.serverRouting,
81
82
  skipInstall: true,
82
83
  })
83
84
  : (0, schematics_1.noop)(),
@@ -198,7 +199,7 @@ function addAppToWorkspaceFile(options, appDir, folderName) {
198
199
  outputPath: `dist/${folderName}`,
199
200
  index: `${sourceRoot}/index.html`,
200
201
  browser: `${sourceRoot}/main.ts`,
201
- polyfills: ['zone.js'],
202
+ polyfills: options.experimentalZoneless ? [] : ['zone.js'],
202
203
  tsConfig: `${projectRoot}tsconfig.app.json`,
203
204
  inlineStyleLanguage,
204
205
  assets: [{ 'glob': '**/*', 'input': `${projectRoot}public` }],
@@ -238,7 +239,7 @@ function addAppToWorkspaceFile(options, appDir, folderName) {
238
239
  : {
239
240
  builder: workspace_models_1.Builders.Karma,
240
241
  options: {
241
- polyfills: ['zone.js', 'zone.js/testing'],
242
+ polyfills: options.experimentalZoneless ? [] : ['zone.js', 'zone.js/testing'],
242
243
  tsConfig: `${projectRoot}tsconfig.spec.json`,
243
244
  inlineStyleLanguage,
244
245
  assets: [{ 'glob': '**/*', 'input': `${projectRoot}public` }],
@@ -2,6 +2,10 @@
2
2
  * Generates a new basic application definition in the "projects" subfolder of the workspace.
3
3
  */
4
4
  export interface Schema {
5
+ /**
6
+ * Create an application that does not utilize zone.js.
7
+ */
8
+ experimentalZoneless?: boolean;
5
9
  /**
6
10
  * Include styles inline in the root component.ts file. Only CSS styles can be included
7
11
  * inline. Default is false, meaning that an external styles file is created and referenced
@@ -34,6 +38,11 @@ export interface Schema {
34
38
  * Creates an application with routing enabled.
35
39
  */
36
40
  routing?: boolean;
41
+ /**
42
+ * Creates a server application using the Server Routing and App Engine APIs (Developer
43
+ * Preview).
44
+ */
45
+ serverRouting?: boolean;
37
46
  /**
38
47
  * Skip installing dependency packages.
39
48
  */
@@ -117,6 +117,15 @@
117
117
  "type": "boolean",
118
118
  "default": false,
119
119
  "x-user-analytics": "ep.ng_ssr"
120
+ },
121
+ "serverRouting": {
122
+ "description": "Creates a server application using the Server Routing and App Engine APIs (Developer Preview).",
123
+ "type": "boolean"
124
+ },
125
+ "experimentalZoneless": {
126
+ "description": "Create an application that does not utilize zone.js.",
127
+ "type": "boolean",
128
+ "default": false
120
129
  }
121
130
  },
122
131
  "required": ["name"]
package/collection.json CHANGED
@@ -23,10 +23,10 @@
23
23
  "schema": "./application/schema.json",
24
24
  "description": "Create an Angular application."
25
25
  },
26
- "e2e": {
26
+ "private-e2e": {
27
27
  "factory": "./e2e",
28
28
  "schema": "./e2e/schema.json",
29
- "description": "Create an Angular e2e application.",
29
+ "description": "PRIVATE API - Do not use.",
30
30
  "hidden": true
31
31
  },
32
32
  "class": {
@@ -2,8 +2,9 @@ import { <% if(changeDetection !== 'Default') { %>ChangeDetectionStrategy, <% }%
2
2
 
3
3
  @Component({<% if(!skipSelector) {%>
4
4
  selector: '<%= selector %>',<%}%><% if(standalone) {%>
5
- standalone: true,
6
- imports: [],<%}%><% if(inlineTemplate) { %>
5
+ imports: [],<%} else { %>
6
+ standalone: false,
7
+ <% }%><% if(inlineTemplate) { %>
7
8
  template: `
8
9
  <p>
9
10
  <%= dasherize(name) %> works!
@@ -42,6 +42,7 @@ function default_1(options) {
42
42
  options.selector =
43
43
  options.selector || buildSelector(options, (project && project.prefix) || '');
44
44
  (0, validation_1.validateHtmlSelector)(options.selector);
45
+ (0, validation_1.validateClassName)(schematics_1.strings.classify(options.name));
45
46
  const skipStyleFile = options.inlineStyle || options.style === schema_1.Style.None;
46
47
  const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
47
48
  options.skipTests ? (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts.template')) : (0, schematics_1.noop)(),
@@ -13,4 +13,5 @@ last 1 Firefox version
13
13
  last 2 Edge major versions
14
14
  last 2 Safari major versions
15
15
  last 2 iOS major versions
16
+ last 2 Android major versions
16
17
  Firefox ESR
@@ -1,8 +1,8 @@
1
1
  import { Directive } from '@angular/core';
2
2
 
3
3
  @Directive({
4
- selector: '[<%= selector %>]'<% if(standalone) {%>,
5
- standalone: true<%}%>
4
+ selector: '[<%= selector %>]'<% if(!standalone) {%>,
5
+ standalone: false<%}%>
6
6
  })
7
7
  export class <%= classify(name) %>Directive {
8
8
 
@@ -40,6 +40,7 @@ function default_1(options) {
40
40
  options.path = parsedPath.path;
41
41
  options.selector = options.selector || buildSelector(options, project.prefix || '');
42
42
  (0, validation_1.validateHtmlSelector)(options.selector);
43
+ (0, validation_1.validateClassName)(schematics_1.strings.classify(options.name));
43
44
  const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
44
45
  options.skipTests ? (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts.template')) : (0, schematics_1.noop)(),
45
46
  (0, schematics_1.applyTemplates)({
@@ -1,24 +1,63 @@
1
1
  # <%= classify(name) %>
2
2
 
3
- This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version <%= angularLatestVersion %>.
3
+ This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version <%= angularLatestVersion %>.
4
4
 
5
5
  ## Code scaffolding
6
6
 
7
- Run `ng generate component component-name --project <%= name %>` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project <%= name %>`.
8
- > Note: Don't forget to add `--project <%= name %>` or else it will be added to the default project in your `angular.json` file.
7
+ Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
9
8
 
10
- ## Build
9
+ ```bash
10
+ ng generate component component-name
11
+ ```
11
12
 
12
- Run `ng build <%= name %>` to build the project. The build artifacts will be stored in the `dist/` directory.
13
+ For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
13
14
 
14
- ## Publishing
15
+ ```bash
16
+ ng generate --help
17
+ ```
15
18
 
16
- After building your library with `ng build <%= name %>`, go to the dist folder `cd dist/<%= dasherize(name) %>` and run `npm publish`.
19
+ ## Building
20
+
21
+ To build the library, run:
22
+
23
+ ```bash
24
+ ng build <%= name %>
25
+ ```
26
+
27
+ This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
28
+
29
+ ### Publishing the Library
30
+
31
+ Once the project is built, you can publish your library by following these steps:
32
+
33
+ 1. Navigate to the `dist` directory:
34
+ ```bash
35
+ cd dist/<%= dasherize(name) %>
36
+ ```
37
+
38
+ 2. Run the `npm publish` command to publish your library to the npm registry:
39
+ ```bash
40
+ npm publish
41
+ ```
17
42
 
18
43
  ## Running unit tests
19
44
 
20
- Run `ng test <%= name %>` to execute the unit tests via [Karma](https://karma-runner.github.io).
45
+ To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
46
+
47
+ ```bash
48
+ ng test
49
+ ```
50
+
51
+ ## Running end-to-end tests
52
+
53
+ For end-to-end (e2e) testing, run:
54
+
55
+ ```bash
56
+ ng e2e
57
+ ```
58
+
59
+ Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
21
60
 
22
- ## Further help
61
+ ## Additional Resources
23
62
 
24
- To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
63
+ For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
package/ng-new/index.js CHANGED
@@ -40,6 +40,8 @@ function default_1(options) {
40
40
  minimal: options.minimal,
41
41
  standalone: options.standalone,
42
42
  ssr: options.ssr,
43
+ serverRouting: options.serverRouting,
44
+ experimentalZoneless: options.experimentalZoneless,
43
45
  };
44
46
  return (0, schematics_1.chain)([
45
47
  (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.empty)(), [
@@ -16,6 +16,10 @@ export interface Schema {
16
16
  * The directory name to create the workspace in.
17
17
  */
18
18
  directory?: string;
19
+ /**
20
+ * Create an application that does not utilize zone.js.
21
+ */
22
+ experimentalZoneless?: boolean;
19
23
  /**
20
24
  * Include styles inline in the component TS file. By default, an external styles file is
21
25
  * created and referenced in the component TypeScript file.
@@ -50,6 +54,11 @@ export interface Schema {
50
54
  * Enable routing in the initial project.
51
55
  */
52
56
  routing?: boolean;
57
+ /**
58
+ * Creates a server application using the Server Routing and App Engine APIs (Developer
59
+ * Preview).
60
+ */
61
+ serverRouting?: boolean;
53
62
  /**
54
63
  * Do not initialize a git repository.
55
64
  */
@@ -138,6 +138,15 @@
138
138
  "description": "Creates an application with Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering) enabled.",
139
139
  "type": "boolean",
140
140
  "x-user-analytics": "ep.ng_ssr"
141
+ },
142
+ "serverRouting": {
143
+ "description": "Creates a server application using the Server Routing and App Engine APIs (Developer Preview).",
144
+ "type": "boolean"
145
+ },
146
+ "experimentalZoneless": {
147
+ "description": "Create an application that does not utilize zone.js.",
148
+ "type": "boolean",
149
+ "default": false
141
150
  }
142
151
  },
143
152
  "required": ["name", "version"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematics/angular",
3
- "version": "19.0.0-next.9",
3
+ "version": "19.0.0-rc.0",
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.9",
26
- "@angular-devkit/schematics": "19.0.0-next.9",
25
+ "@angular-devkit/core": "19.0.0-rc.0",
26
+ "@angular-devkit/schematics": "19.0.0-rc.0",
27
27
  "jsonc-parser": "3.3.1"
28
28
  },
29
29
  "packageManager": "yarn@4.5.0",
@@ -1,8 +1,8 @@
1
1
  import { Pipe, PipeTransform } from '@angular/core';
2
2
 
3
3
  @Pipe({
4
- name: '<%= camelize(name) %>'<% if(standalone) {%>,
5
- standalone: true<%}%>
4
+ name: '<%= camelize(name) %>'<% if(!standalone) {%>,
5
+ standalone: false<%}%>
6
6
  })
7
7
  export class <%= classify(name) %>Pipe implements PipeTransform {
8
8
 
@@ -0,0 +1,13 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { ServerModule } from '@angular/platform-server';<% if(serverRouting) { %>
3
+ import { provideServerRoutesConfig } from '@angular/ssr';<% } %>
4
+ import { AppComponent } from './app.component';
5
+ import { AppModule } from './app.module';<% if(serverRouting) { %>
6
+ import { serverRoutes } from './app.routes.server';<% } %>
7
+
8
+ @NgModule({
9
+ imports: [AppModule, ServerModule],<% if(serverRouting) { %>
10
+ providers: [provideServerRoutesConfig(serverRoutes)],<% } %>
11
+ bootstrap: [AppComponent],
12
+ })
13
+ export class AppServerModule {}
@@ -0,0 +1,8 @@
1
+ import { RenderMode, ServerRoute } from '@angular/ssr';
2
+
3
+ export const serverRoutes: ServerRoute[] = [
4
+ {
5
+ path: '**',
6
+ renderMode: RenderMode.Prerender
7
+ }
8
+ ];
@@ -0,0 +1,14 @@
1
+ import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
2
+ import { provideServerRendering } from '@angular/platform-server';<% if(serverRouting) { %>
3
+ import { provideServerRoutesConfig } from '@angular/ssr';<% } %>
4
+ import { appConfig } from './app.config';<% if(serverRouting) { %>
5
+ import { serverRoutes } from './app.routes.server';<% } %>
6
+
7
+ const serverConfig: ApplicationConfig = {
8
+ providers: [
9
+ provideServerRendering(),<% if(serverRouting) { %>
10
+ provideServerRoutesConfig(serverRoutes)<% } %>
11
+ ]
12
+ };
13
+
14
+ export const config = mergeApplicationConfig(appConfig, serverConfig);
@@ -0,0 +1,8 @@
1
+ import { RenderMode, ServerRoute } from '@angular/ssr';
2
+
3
+ export const serverRoutes: ServerRoute[] = [
4
+ {
5
+ path: '**',
6
+ renderMode: RenderMode.Prerender
7
+ }
8
+ ];
@@ -0,0 +1 @@
1
+ export { AppServerModule as default } from './app/app.module.server';
@@ -0,0 +1,7 @@
1
+ import { bootstrapApplication } from '@angular/platform-browser';
2
+ import { AppComponent } from './app/app.component';
3
+ import { config } from './app/app.config.server';
4
+
5
+ const bootstrap = () => bootstrapApplication(AppComponent, config);
6
+
7
+ export default bootstrap;
package/server/index.js CHANGED
@@ -83,11 +83,14 @@ function updateConfigFileApplicationBuilder(options) {
83
83
  return;
84
84
  }
85
85
  const buildTarget = project.targets.get('build');
86
- if (buildTarget?.builder !== workspace_models_1.Builders.Application) {
87
- throw new schematics_1.SchematicsException(`This schematic requires "${workspace_models_1.Builders.Application}" to be used as a build builder.`);
86
+ if (!buildTarget) {
87
+ return;
88
88
  }
89
89
  buildTarget.options ??= {};
90
90
  buildTarget.options['server'] = node_path_1.posix.join(project.sourceRoot ?? node_path_1.posix.join(project.root, 'src'), serverMainEntryName);
91
+ if (options.serverRouting) {
92
+ buildTarget.options['outputMode'] = 'static';
93
+ }
91
94
  });
92
95
  }
93
96
  function updateTsConfigFile(tsConfigPath) {
@@ -137,7 +140,8 @@ function default_1(options) {
137
140
  if (!clientBuildTarget) {
138
141
  throw (0, project_targets_1.targetBuildNotFoundError)();
139
142
  }
140
- const isUsingApplicationBuilder = clientBuildTarget.builder === workspace_models_1.Builders.Application;
143
+ const isUsingApplicationBuilder = clientBuildTarget.builder === workspace_models_1.Builders.Application ||
144
+ clientBuildTarget.builder === workspace_models_1.Builders.BuildApplication;
141
145
  if (clientProject.targets.has('server') ||
142
146
  (isUsingApplicationBuilder && clientBuildTarget.options?.server !== undefined)) {
143
147
  // Server has already been added.
@@ -146,12 +150,18 @@ function default_1(options) {
146
150
  const clientBuildOptions = clientBuildTarget.options;
147
151
  const browserEntryPoint = await (0, util_1.getMainFilePath)(host, options.project);
148
152
  const isStandalone = (0, ng_ast_utils_1.isStandaloneApp)(host, browserEntryPoint);
149
- const templateSource = (0, schematics_1.apply)((0, schematics_1.url)(isStandalone ? './files/standalone-src' : './files/src'), [
153
+ const sourceRoot = clientProject.sourceRoot ?? (0, core_1.join)((0, core_1.normalize)(clientProject.root), 'src');
154
+ let filesUrl = `./files/${isUsingApplicationBuilder ? 'application-builder/' : 'server-builder/'}`;
155
+ filesUrl += isStandalone ? 'standalone-src' : 'ngmodule-src';
156
+ const templateSource = (0, schematics_1.apply)((0, schematics_1.url)(filesUrl), [
157
+ options.serverRouting
158
+ ? (0, schematics_1.noop)()
159
+ : (0, schematics_1.filter)((path) => !path.endsWith('app.routes.server.ts.template')),
150
160
  (0, schematics_1.applyTemplates)({
151
161
  ...schematics_1.strings,
152
162
  ...options,
153
163
  }),
154
- (0, schematics_1.move)((0, core_1.join)((0, core_1.normalize)(clientProject.root), 'src')),
164
+ (0, schematics_1.move)(sourceRoot),
155
165
  ]);
156
166
  const clientTsConfig = (0, core_1.normalize)(clientBuildOptions.tsConfig);
157
167
  const tsConfigExtends = (0, core_1.basename)(clientTsConfig);
@@ -164,7 +174,7 @@ function default_1(options) {
164
174
  updateTsConfigFile(clientBuildOptions.tsConfig),
165
175
  ]
166
176
  : [
167
- (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files/root'), [
177
+ (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files/server-builder/root'), [
168
178
  (0, schematics_1.applyTemplates)({
169
179
  ...schematics_1.strings,
170
180
  ...options,
@@ -6,6 +6,11 @@ export interface Schema {
6
6
  * The name of the project.
7
7
  */
8
8
  project: string;
9
+ /**
10
+ * Creates a server application using the Server Routing and App Engine APIs (Developer
11
+ * Preview).
12
+ */
13
+ serverRouting?: boolean;
9
14
  /**
10
15
  * Do not install packages for dependencies.
11
16
  */
@@ -17,6 +17,10 @@
17
17
  "description": "Do not install packages for dependencies.",
18
18
  "type": "boolean",
19
19
  "default": false
20
+ },
21
+ "serverRouting": {
22
+ "description": "Creates a server application using the Server Routing and App Engine APIs (Developer Preview).",
23
+ "type": "boolean"
20
24
  }
21
25
  },
22
26
  "required": ["project"]
@@ -8,6 +8,7 @@
8
8
  "resources": {
9
9
  "files": [
10
10
  "/favicon.ico",
11
+ "/index.csr.html",
11
12
  "/index.html",
12
13
  "/manifest.webmanifest",
13
14
  "/*.css",
@@ -1,57 +1,72 @@
1
- import { APP_BASE_HREF } from '@angular/common';
2
- import { CommonEngine } from '@angular/ssr/node';
1
+ import {
2
+ AngularNodeAppEngine,
3
+ createNodeRequestHandler,
4
+ isMainModule,
5
+ writeResponseToNodeResponse,
6
+ } from '@angular/ssr/node';
3
7
  import express from 'express';
8
+ import { dirname, resolve } from 'node:path';
4
9
  import { fileURLToPath } from 'node:url';
5
- import { dirname, join, resolve } from 'node:path';
6
- import <% if (isStandalone) { %>bootstrap<% } else { %>AppServerModule<% } %> from './src/main.server';
7
10
 
8
- // The Express app is exported so that it can be used by serverless Functions.
9
- export function app(): express.Express {
10
- const server = express();
11
- const serverDistFolder = dirname(fileURLToPath(import.meta.url));
12
- const browserDistFolder = resolve(serverDistFolder, '../<%= browserDistDirectory %>');
13
- const indexHtml = join(serverDistFolder, 'index.server.html');
11
+ const serverDistFolder = dirname(fileURLToPath(import.meta.url));
12
+ const browserDistFolder = resolve(serverDistFolder, '../<%= browserDistDirectory %>');
14
13
 
15
- const commonEngine = new CommonEngine();
14
+ const app = express();
15
+ const angularApp = new AngularNodeAppEngine();
16
16
 
17
- server.set('view engine', 'html');
18
- server.set('views', browserDistFolder);
17
+ /**
18
+ * Example Express Rest API endpoints can be defined here.
19
+ * Uncomment and define endpoints as necessary.
20
+ *
21
+ * Example:
22
+ * ```ts
23
+ * app.get('/api/**', (req, res) => {
24
+ * // Handle API request
25
+ * });
26
+ * ```
27
+ */
19
28
 
20
- // Example Express Rest API endpoints
21
- // server.get('/api/**', (req, res) => { });
22
- // Serve static files from /<%= browserDistDirectory %>
23
- server.get('**', express.static(browserDistFolder, {
29
+ /**
30
+ * Serve static files from /<%= browserDistDirectory %>
31
+ */
32
+ app.get(
33
+ '**',
34
+ express.static(browserDistFolder, {
24
35
  maxAge: '1y',
25
36
  index: 'index.html',
26
- }));
37
+ setHeaders: (res) => {
38
+ const headers = angularApp.getPrerenderHeaders(res.req);
39
+ for (const [key, value] of headers) {
40
+ res.setHeader(key, value);
41
+ }
42
+ },
43
+ }),
44
+ );
27
45
 
28
- // All regular routes use the Angular engine
29
- server.get('**', (req, res, next) => {
30
- const { protocol, originalUrl, baseUrl, headers } = req;
46
+ /**
47
+ * Handle all other requests by rendering the Angular application.
48
+ */
49
+ app.get('**', (req, res, next) => {
50
+ angularApp
51
+ .render(req)
52
+ .then((response) =>
53
+ response ? writeResponseToNodeResponse(response, res) : next(),
54
+ )
55
+ .catch(next);
56
+ });
31
57
 
32
- commonEngine
33
- .render({
34
- <% if (isStandalone) { %>bootstrap<% } else { %>bootstrap: AppServerModule<% } %>,
35
- documentFilePath: indexHtml,
36
- url: `${protocol}://${headers.host}${originalUrl}`,
37
- publicPath: browserDistFolder,
38
- providers: [{ provide: APP_BASE_HREF, useValue: baseUrl }],
39
- })
40
- .then((html) => res.send(html))
41
- .catch((err) => next(err));
42
- });
43
-
44
- return server;
45
- }
46
-
47
- function run(): void {
58
+ /**
59
+ * Start the server if this module is the main entry point.
60
+ * The server listens on the port defined by the `PORT` environment variable, or defaults to 4000.
61
+ */
62
+ if (isMainModule(import.meta.url)) {
48
63
  const port = process.env['PORT'] || 4000;
49
-
50
- // Start up the Node server
51
- const server = app();
52
- server.listen(port, () => {
64
+ app.listen(port, () => {
53
65
  console.log(`Node Express server listening on http://localhost:${port}`);
54
66
  });
55
67
  }
56
68
 
57
- run();
69
+ /**
70
+ * The request handler used by the Angular CLI (dev-server and during build).
71
+ */
72
+ export const reqHandler = createNodeRequestHandler(app);
@@ -0,0 +1,65 @@
1
+ import { APP_BASE_HREF } from '@angular/common';
2
+ import { CommonEngine, isMainModule } from '@angular/ssr/node';
3
+ import express from 'express';
4
+ import { dirname, join, resolve } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+ import <% if (isStandalone) { %>bootstrap<% } else { %>AppServerModule<% } %> from './main.server';
7
+
8
+ const serverDistFolder = dirname(fileURLToPath(import.meta.url));
9
+ const browserDistFolder = resolve(serverDistFolder, '../<%= browserDistDirectory %>');
10
+ const indexHtml = join(serverDistFolder, 'index.server.html');
11
+
12
+ const app = express();
13
+ const commonEngine = new CommonEngine();
14
+
15
+ /**
16
+ * Example Express Rest API endpoints can be defined here.
17
+ * Uncomment and define endpoints as necessary.
18
+ *
19
+ * Example:
20
+ * ```ts
21
+ * app.get('/api/**', (req, res) => {
22
+ * // Handle API request
23
+ * });
24
+ * ```
25
+ */
26
+
27
+ /**
28
+ * Serve static files from /<%= browserDistDirectory %>
29
+ */
30
+ app.get(
31
+ '**',
32
+ express.static(browserDistFolder, {
33
+ maxAge: '1y',
34
+ index: 'index.html'
35
+ }),
36
+ );
37
+
38
+ /**
39
+ * Handle all other requests by rendering the Angular application.
40
+ */
41
+ app.get('**', (req, res, next) => {
42
+ const { protocol, originalUrl, baseUrl, headers } = req;
43
+
44
+ commonEngine
45
+ .render({
46
+ <% if (isStandalone) { %>bootstrap<% } else { %>bootstrap: AppServerModule<% } %>,
47
+ documentFilePath: indexHtml,
48
+ url: `${protocol}://${headers.host}${originalUrl}`,
49
+ publicPath: browserDistFolder,
50
+ providers: [{ provide: APP_BASE_HREF, useValue: baseUrl }],
51
+ })
52
+ .then((html) => res.send(html))
53
+ .catch((err) => next(err));
54
+ });
55
+
56
+ /**
57
+ * Start the server if this module is the main entry point.
58
+ * The server listens on the port defined by the `PORT` environment variable, or defaults to 4000.
59
+ */
60
+ if (isMainModule(import.meta.url)) {
61
+ const port = process.env['PORT'] || 4000;
62
+ app.listen(port, () => {
63
+ console.log(`Node Express server listening on http://localhost:${port}`);
64
+ });
65
+ }
@@ -5,7 +5,7 @@ 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';
8
- import <% if (isStandalone) { %>bootstrap<% } else { %>AppServerModule<% } %> from './src/main.server';
8
+ import <% if (isStandalone) { %>bootstrap<% } else { %>AppServerModule<% } %> from './main.server';
9
9
 
10
10
  // The Express app is exported so that it can be used by serverless Functions.
11
11
  export function app(): express.Express {
package/ssr/index.js CHANGED
@@ -108,15 +108,14 @@ function updateApplicationBuilderTsConfigRule(options) {
108
108
  // No tsconfig path
109
109
  return;
110
110
  }
111
- const tsConfig = new json_file_1.JSONFile(host, tsConfigPath);
112
- const filesAstNode = tsConfig.get(['files']);
113
- const serverFilePath = 'server.ts';
114
- if (Array.isArray(filesAstNode) && !filesAstNode.some(({ text }) => text === serverFilePath)) {
115
- tsConfig.modify(['files'], [...filesAstNode, serverFilePath]);
116
- }
111
+ const json = new json_file_1.JSONFile(host, tsConfigPath);
112
+ const filesPath = ['files'];
113
+ const files = new Set(json.get(filesPath) ?? []);
114
+ files.add('src/server.ts');
115
+ json.modify(filesPath, [...files]);
117
116
  };
118
117
  }
119
- function updateApplicationBuilderWorkspaceConfigRule(projectRoot, options, { logger }) {
118
+ function updateApplicationBuilderWorkspaceConfigRule(projectSourceRoot, options, { logger }) {
120
119
  return (0, utility_1.updateWorkspace)((workspace) => {
121
120
  const buildTarget = workspace.projects.get(options.project)?.targets.get('build');
122
121
  if (!buildTarget) {
@@ -140,14 +139,15 @@ function updateApplicationBuilderWorkspaceConfigRule(projectRoot, options, { log
140
139
  buildTarget.options = {
141
140
  ...buildTarget.options,
142
141
  outputPath,
143
- prerender: true,
142
+ outputMode: options.serverRouting ? 'server' : undefined,
143
+ prerender: options.serverRouting ? undefined : true,
144
144
  ssr: {
145
- entry: (0, core_1.join)((0, core_1.normalize)(projectRoot), 'server.ts'),
145
+ entry: (0, core_1.join)((0, core_1.normalize)(projectSourceRoot), 'server.ts'),
146
146
  },
147
147
  };
148
148
  });
149
149
  }
150
- function updateWebpackBuilderWorkspaceConfigRule(options) {
150
+ function updateWebpackBuilderWorkspaceConfigRule(projectSourceRoot, options) {
151
151
  return (0, utility_1.updateWorkspace)((workspace) => {
152
152
  const projectName = options.project;
153
153
  const project = workspace.projects.get(projectName);
@@ -156,7 +156,7 @@ function updateWebpackBuilderWorkspaceConfigRule(options) {
156
156
  }
157
157
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
158
158
  const serverTarget = project.targets.get('server');
159
- (serverTarget.options ??= {}).main = (0, core_1.join)((0, core_1.normalize)(project.root), 'server.ts');
159
+ (serverTarget.options ??= {}).main = node_path_1.posix.join(projectSourceRoot, 'server.ts');
160
160
  const serveSSRTarget = project.targets.get(SERVE_SSR_TARGET_NAME);
161
161
  if (serveSSRTarget) {
162
162
  return;
@@ -216,7 +216,7 @@ function updateWebpackBuilderServerTsConfigRule(options) {
216
216
  }
217
217
  const tsConfig = new json_file_1.JSONFile(host, tsConfigPath);
218
218
  const filesAstNode = tsConfig.get(['files']);
219
- const serverFilePath = 'server.ts';
219
+ const serverFilePath = 'src/server.ts';
220
220
  if (Array.isArray(filesAstNode) && !filesAstNode.some(({ text }) => text === serverFilePath)) {
221
221
  tsConfig.modify(['files'], [...filesAstNode, serverFilePath]);
222
222
  }
@@ -242,7 +242,7 @@ function addDependencies({ skipInstall }, isUsingApplicationBuilder) {
242
242
  }
243
243
  return (0, schematics_1.chain)(rules);
244
244
  }
245
- function addServerFile(options, isStandalone) {
245
+ function addServerFile(projectSourceRoot, options, isStandalone) {
246
246
  return async (host) => {
247
247
  const projectName = options.project;
248
248
  const workspace = await (0, utility_1.readWorkspace)(host);
@@ -254,14 +254,15 @@ function addServerFile(options, isStandalone) {
254
254
  const browserDistDirectory = isUsingApplicationBuilder
255
255
  ? (await getApplicationBuilderOutputPaths(host, projectName)).browser
256
256
  : await getLegacyOutputPaths(host, projectName, 'build');
257
- return (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)(`./files/${isUsingApplicationBuilder ? 'application-builder' : 'server-builder'}`), [
257
+ const applicationBuilderFiles = 'application-builder' + (options.serverRouting ? '' : '-common-engine');
258
+ return (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)(`./files/${isUsingApplicationBuilder ? applicationBuilderFiles : 'server-builder'}`), [
258
259
  (0, schematics_1.applyTemplates)({
259
260
  ...core_1.strings,
260
261
  ...options,
261
262
  browserDistDirectory,
262
263
  isStandalone,
263
264
  }),
264
- (0, schematics_1.move)(project.root),
265
+ (0, schematics_1.move)(projectSourceRoot),
265
266
  ]));
266
267
  };
267
268
  }
@@ -275,6 +276,7 @@ function default_1(options) {
275
276
  throw (0, project_targets_1.targetBuildNotFoundError)();
276
277
  }
277
278
  const isUsingApplicationBuilder = usingApplicationBuilder(clientProject);
279
+ const sourceRoot = clientProject.sourceRoot ?? node_path_1.posix.join(clientProject.root, 'src');
278
280
  return (0, schematics_1.chain)([
279
281
  (0, schematics_1.schematic)('server', {
280
282
  ...options,
@@ -282,14 +284,14 @@ function default_1(options) {
282
284
  }),
283
285
  ...(isUsingApplicationBuilder
284
286
  ? [
285
- updateApplicationBuilderWorkspaceConfigRule(clientProject.root, options, context),
287
+ updateApplicationBuilderWorkspaceConfigRule(sourceRoot, options, context),
286
288
  updateApplicationBuilderTsConfigRule(options),
287
289
  ]
288
290
  : [
289
291
  updateWebpackBuilderServerTsConfigRule(options),
290
- updateWebpackBuilderWorkspaceConfigRule(options),
292
+ updateWebpackBuilderWorkspaceConfigRule(sourceRoot, options),
291
293
  ]),
292
- addServerFile(options, isStandalone),
294
+ addServerFile(sourceRoot, options, isStandalone),
293
295
  addScriptsRule(options, isUsingApplicationBuilder),
294
296
  addDependencies(options, isUsingApplicationBuilder),
295
297
  ]);
package/ssr/schema.d.ts CHANGED
@@ -3,6 +3,11 @@ export interface Schema {
3
3
  * The name of the project.
4
4
  */
5
5
  project: string;
6
+ /**
7
+ * Creates a server application using the Server Routing and App Engine APIs (Developer
8
+ * Preview).
9
+ */
10
+ serverRouting?: boolean;
6
11
  /**
7
12
  * Skip installing dependency packages.
8
13
  */
package/ssr/schema.json CHANGED
@@ -15,6 +15,12 @@
15
15
  "description": "Skip installing dependency packages.",
16
16
  "type": "boolean",
17
17
  "default": false
18
+ },
19
+ "serverRouting": {
20
+ "description": "Creates a server application using the Server Routing and App Engine APIs (Developer Preview).",
21
+ "x-prompt": "Would you like to use the Server Routing and App Engine APIs (Developer Preview) for this server application?",
22
+ "type": "boolean",
23
+ "default": false
18
24
  }
19
25
  },
20
26
  "required": ["project"],
@@ -9,7 +9,7 @@
9
9
  "@types/node": "^18.18.0",
10
10
  "browser-sync": "^3.0.0",
11
11
  "express": "^4.18.2",
12
- "jasmine-core": "~5.3.0",
12
+ "jasmine-core": "~5.4.0",
13
13
  "jasmine-spec-reporter": "~7.0.0",
14
14
  "karma-chrome-launcher": "~3.2.0",
15
15
  "karma-coverage": "~2.2.0",
@@ -15,6 +15,6 @@ exports.latestVersions = {
15
15
  ...dependencies,
16
16
  // As Angular CLI works with same minor versions of Angular Framework, a tilde match for the current
17
17
  Angular: dependencies['@angular/core'],
18
- DevkitBuildAngular: '^19.0.0-next.9',
19
- AngularSSR: '^19.0.0-next.9',
18
+ DevkitBuildAngular: '^19.0.0-rc.0',
19
+ AngularSSR: '^19.0.0-rc.0',
20
20
  };
@@ -28,7 +28,7 @@ export declare enum Builders {
28
28
  NgPackagr = "@angular-devkit/build-angular:ng-packagr",
29
29
  DevServer = "@angular-devkit/build-angular:dev-server",
30
30
  ExtractI18n = "@angular-devkit/build-angular:extract-i18n",
31
- Protractor = "@angular-devkit/build-angular:protractor",
31
+ Protractor = "@angular-devkit/build-angular:private-protractor",
32
32
  BuildApplication = "@angular/build:application"
33
33
  }
34
34
  export interface FileReplacements {
@@ -33,6 +33,6 @@ var Builders;
33
33
  Builders["NgPackagr"] = "@angular-devkit/build-angular:ng-packagr";
34
34
  Builders["DevServer"] = "@angular-devkit/build-angular:dev-server";
35
35
  Builders["ExtractI18n"] = "@angular-devkit/build-angular:extract-i18n";
36
- Builders["Protractor"] = "@angular-devkit/build-angular:protractor";
36
+ Builders["Protractor"] = "@angular-devkit/build-angular:private-protractor";
37
37
  Builders["BuildApplication"] = "@angular/build:application";
38
38
  })(Builders || (exports.Builders = Builders = {}));
@@ -1,27 +1,59 @@
1
1
  # <%= utils.classify(name) %>
2
2
 
3
- This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version <%= version %>.
3
+ This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version <%= version %>.
4
4
 
5
5
  ## Development server
6
6
 
7
- Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.
7
+ To start a local development server, run:
8
+
9
+ ```bash
10
+ ng serve
11
+ ```
12
+
13
+ Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.
8
14
 
9
15
  ## Code scaffolding
10
16
 
11
- Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
17
+ Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
18
+
19
+ ```bash
20
+ ng generate component component-name
21
+ ```
22
+
23
+ For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
24
+
25
+ ```bash
26
+ ng generate --help
27
+ ```
12
28
 
13
- ## Build
29
+ ## Building
14
30
 
15
- Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
31
+ To build the project run:
32
+
33
+ ```bash
34
+ ng build
35
+ ```
36
+
37
+ This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.
16
38
 
17
39
  ## Running unit tests
18
40
 
19
- Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
41
+ To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
42
+
43
+ ```bash
44
+ ng test
45
+ ```
20
46
 
21
47
  ## Running end-to-end tests
22
48
 
23
- Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
49
+ For end-to-end (e2e) testing, run:
50
+
51
+ ```bash
52
+ ng e2e
53
+ ```
54
+
55
+ Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
24
56
 
25
- ## Further help
57
+ ## Additional Resources
26
58
 
27
- To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
59
+ For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.