MCPcopy
hub / github.com/angular/angular / renderModule

Function renderModule

packages/platform-server/src/utils.ts:283–309  ·  view source on GitHub ↗
(
  moduleType: Type<T>,
  options: {
    document?: string | Document;
    url?: string;
    extraProviders?: StaticProvider[];
    allowedHosts?: Readonly<string>[];
  },
)

Source from the content-addressed store, hash-verified

281 * @publicApi
282 */
283export async function renderModule<T>(
284 moduleType: Type<T>,
285 options: {
286 document?: string | Document;
287 url?: string;
288 extraProviders?: StaticProvider[];
289 allowedHosts?: Readonly<string>[];
290 },
291): Promise<string> {
292 const {document, url, extraProviders: platformProviders, allowedHosts} = options;
293 validateAllowedHosts(url, allowedHosts);
294 const platformRef = createServerPlatform({document, url, platformProviders});
295 try {
296 const moduleRef = await platformRef.bootstrapModule(moduleType);
297 const applicationRef = moduleRef.injector.get(ApplicationRef);
298
299 const measuringLabel = 'whenStable';
300 startMeasuring(measuringLabel);
301 // Block until application is stable.
302 await applicationRef.whenStable();
303 stopMeasuring(measuringLabel);
304
305 return await renderInternal(platformRef, applicationRef);
306 } finally {
307 await asyncDestroyPlatform(platformRef);
308 }
309}
310
311/**
312 * Bootstraps an instance of an Angular application and renders it to a string.

Callers 5

utils_spec.tsFile · 0.90
runTestFunction · 0.90
server.tsFile · 0.90

Calls 9

validateAllowedHostsFunction · 0.85
createServerPlatformFunction · 0.85
startMeasuringFunction · 0.85
stopMeasuringFunction · 0.85
renderInternalFunction · 0.85
asyncDestroyPlatformFunction · 0.85
bootstrapModuleMethod · 0.80
getMethod · 0.65
whenStableMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…