Repository: angular/angular
File: packages/platform-browser/src/browser.ts (TypeScript)

Code before:
 * @publicApi
 */
export async function createApplication(
  options?: ApplicationConfig,
  context?: BootstrapContext,
): Promise<ApplicationRef> {
  await resolveJitResources();
  return internalCreateApplication(createProvidersConfig(options, context));
}

function createProvidersConfig(options?: ApplicationConfig, context?: BootstrapContext) {
  return {
    platformRef: context?.platformRef,
    appProviders: [...BROWSER_MODULE_PROVIDERS, ...(options?.providers ?? [])],
    platformProviders: INTERNAL_BROWSER_PLATFORM_PROVIDERS,
  };
}

/** Attempt to resolve component resources before bootstrapping in JIT mode. */
async function resolveJitResources(): Promise<void> {
  if ((typeof ngJitMode === 'undefined' || ngJitMode) && typeof fetch === 'function') {
    try {
      return await resolveComponentResources(fetch);
    } catch (error) {
      // Log, but don't block bootstrapping on error.
      console.log(error);
    }
  }
}

/**
 * Returns a set of providers required to setup [Testability](api/core/Testability) for an
 * application bootstrapped using the `bootstrapApplication` function. The set of providers is
 * needed to support testing an application with Protractor (which relies on the Testability APIs
 * to be present).
 *
 * @returns An array of providers required to setup Testability for an application and make it
 *     available for testing using Protractor.
 *
 * @publicApi
 */
export function provideProtractorTestingSupport(): Provider[] {
  // Return a copy to prevent changes to the original array in case any in-place
  // alterations are performed to the `provideProtractorTestingSupport` call results in app
  // code.
  return [...TESTABILITY_PROVIDERS];
}

export function initDomAdapter() {
  BrowserDomAdapter.makeCurrent();
}

Review comment (suggestion):
Nit

```suggestion
      console.error(error);
```

Code after:
 *     rendering, where the platform is created for each request.
 * @returns A promise that returns an `ApplicationRef` instance once resolved.
 *
 * @publicApi
 */
export async function createApplication(
  options?: ApplicationConfig,
  context?: BootstrapContext,
): Promise<ApplicationRef> {
  if ((typeof ngJitMode === 'undefined' || ngJitMode) && typeof fetch === 'function') {
    await resolveJitResources();
  }

  return internalCreateApplication(createProvidersConfig(options, context));
}

function createProvidersConfig(options?: ApplicationConfig, context?: BootstrapContext) {
  return {
    platformRef: context?.platformRef,
    appProviders: [...BROWSER_MODULE_PROVIDERS, ...(options?.providers ?? [])],
    platformProviders: INTERNAL_BROWSER_PLATFORM_PROVIDERS,
  };
}

/** Attempt to resolve component resources before bootstrapping in JIT mode. */
async function resolveJitResources(): Promise<void> {
  try {
    return await resolveComponentResources(fetch);
  } catch (error) {
    // Log, but don't block bootstrapping on error.
    // tslint:disable-next-line:no-console
    console.error(error);
  }
}

/**
 * Returns a set of providers required to setup [Testability](api/core/Testability) for an
 * application bootstrapped using the `bootstrapApplication` function. The set of providers is
 * needed to support testing an application with Protractor (which relies on the Testability APIs
 * to be present).
 *
 * @returns An array of providers required to setup Testability for an application and make it
 *     available for testing using Protractor.
 *
 * @publicApi
 */
export function provideProtractorTestingSupport(): Provider[] {
  // Return a copy to prevent changes to the original array in case any in-place
  // alterations are performed to the `provideProtractorTestingSupport` call results in app
  // code.
  return [...TESTABILITY_PROVIDERS];