import { createNgModuleRef , Injector , Type } from '@angular/core' ; import { EXAMPLE_COMPONENTS , EXAMPLE_COMPONENTS_LOADER } from './example-module' ; /**
 * Asynchronously loads the specified example and returns its component and
 * an injector instantiated from the containing example module.
 *
 * This is used in the `dev-app` and `e2e-app` and assumes ESBuild having created
 * entry-points for the example modules under the `<host>/bundles/` URL.
 */ export async function loadExample ( name , injector ) { const { componentName , module } = EXAMPLE_COMPONENTS [ name ] ; const moduleExports = await EXAMPLE_COMPONENTS_LOADER . get ( module . importSpecifier ) ! ( ) ; const moduleType = moduleExports [ module . name ] ; const componentType = moduleExports [ componentName ] ; const moduleRef = createNgModuleRef ( moduleType , injector ) ; return { component : componentType , injector : moduleRef . injector , } ; }