MCPcopy Create free account
hub / github.com/angular/angular / renderModule

Function renderModule

packages/platform-server/src/utils.ts:322–351  ·  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

320 * @publicApi
321 */
322export async function renderModule<T>(
323 moduleType: Type<T>,
324 options: {
325 document?: string | Document;
326 url?: string;
327 extraProviders?: StaticProvider[];
328 allowedHosts?: Readonly<string>[];
329 },
330): Promise<string> {
331 const {document, url, extraProviders: platformProviders, allowedHosts} = options;
332 validateAllowedHosts(url, allowedHosts);
333 const platformRef = createServerPlatform({document, url, platformProviders});
334 try {
335 const moduleRef = await platformRef.bootstrapModule(moduleType);
336 if (platformRef.destroyed || moduleRef.injector.destroyed) {
337 return '';
338 }
339 const applicationRef = moduleRef.injector.get(ApplicationRef);
340
341 const measuringLabel = 'whenStable';
342 startMeasuring(measuringLabel);
343 // Block until application is stable.
344 await applicationRef.whenStable();
345 stopMeasuring(measuringLabel);
346
347 return await renderInternal(platformRef, applicationRef);
348 } finally {
349 await asyncDestroyPlatform(platformRef);
350 }
351}
352
353/**
354 * 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