mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-18 20:02:40 +08:00
- Exposed several utility functions as private APIs to support the integration with the build system. - Removed `isDevMode` and caching logic from `AngularAppEngine`. This was necessary to better handle updates when using Vite. Instead, `AngularServerApp` is now treated as a singleton to simplify management. - Switched asset storage from an `Object` to a `Map` in the manifest for improved efficiency and consistency. This refactor sets the groundwork for seamless wiring with the build system.
56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.dev/license
|
|
*/
|
|
|
|
import { Component } from '@angular/core';
|
|
import { bootstrapApplication } from '@angular/platform-browser';
|
|
import { provideServerRendering } from '@angular/platform-server';
|
|
import { RouterOutlet, Routes, provideRouter } from '@angular/router';
|
|
import { setAngularAppManifest } from '../src/manifest';
|
|
|
|
/**
|
|
* Configures the Angular application for testing by setting up the Angular app manifest,
|
|
* configuring server-side rendering, and bootstrapping the application with the provided routes.
|
|
* This function generates a basic HTML template with a base href and sets up the necessary
|
|
* Angular components and providers for testing purposes.
|
|
*
|
|
* @param routes - An array of route definitions to be used by the Angular Router.
|
|
* @param [baseHref=''] - An optional base href to be used in the HTML template.
|
|
*/
|
|
export function setAngularAppTestingManifest(routes: Routes, baseHref = ''): void {
|
|
setAngularAppManifest({
|
|
inlineCriticalCss: false,
|
|
assets: new Map(
|
|
Object.entries({
|
|
'index.server.html': async () =>
|
|
`
|
|
<html>
|
|
<head>
|
|
<base href="/${baseHref}" />
|
|
</head>
|
|
<body>
|
|
<app-root></app-root>
|
|
</body>
|
|
</html>`,
|
|
}),
|
|
),
|
|
bootstrap: () => () => {
|
|
@Component({
|
|
standalone: true,
|
|
selector: 'app-root',
|
|
template: '<router-outlet />',
|
|
imports: [RouterOutlet],
|
|
})
|
|
class AppComponent {}
|
|
|
|
return bootstrapApplication(AppComponent, {
|
|
providers: [provideServerRendering(), provideRouter(routes)],
|
|
});
|
|
},
|
|
});
|
|
}
|