@@ -15,15 +15,13 @@ import {
1515 Compiler ,
1616 CompilerFactory ,
1717 Component ,
18- effect ,
1918 EnvironmentInjector ,
2019 InjectionToken ,
2120 Injector ,
2221 LOCALE_ID ,
2322 NgModule ,
2423 NgZone ,
2524 PlatformRef ,
26- ProviderToken ,
2725 provideZoneChangeDetection ,
2826 RendererFactory2 ,
2927 TemplateRef ,
@@ -48,6 +46,7 @@ import {ApplicationRef} from '../src/application/application_ref';
4846import { NoopNgZone } from '../src/zone/ng_zone' ;
4947import { ComponentFixtureNoNgZone , inject , TestBed , waitForAsync , withModule } from '../testing' ;
5048import { take } from 'rxjs/operators' ;
49+ import { compileNgModuleFactory } from '../src/application/application_ngmodule_factory_compiler' ;
5150
5251let serverPlatformModule : Promise < Type < ServerModule > > | null = null ;
5352if ( isNode ) {
@@ -677,45 +676,38 @@ describe('bootstrap', () => {
677676 initializerDone = true ;
678677 } , 1 ) ;
679678
680- const compilerFactory : CompilerFactory = defaultPlatform . injector . get ( CompilerFactory , null ) ! ;
681- const moduleFactory = compilerFactory
682- . createCompiler ( )
683- . compileModuleSync (
684- await createModule ( [ { provide : APP_INITIALIZER , useValue : ( ) => promise , multi : true } ] ) ,
685- ) ;
679+ const moduleType = await createModule ( [
680+ { provide : APP_INITIALIZER , useValue : ( ) => promise , multi : true } ,
681+ ] ) ;
682+ const moduleFactory = await compileNgModuleFactory ( defaultPlatform . injector , { } , moduleType ) ;
683+
686684 defaultPlatform . bootstrapModuleFactory ( moduleFactory ) . then ( ( _ ) => {
687685 expect ( initializerDone ) . toBe ( true ) ;
688686 } ) ;
689687 } ) ) ;
690688
691689 it ( 'should rethrow sync errors even if the exceptionHandler is not rethrowing' , waitForAsync ( async ( ) => {
692- const compilerFactory : CompilerFactory = defaultPlatform . injector . get ( CompilerFactory , null ) ! ;
693- const moduleFactory = compilerFactory . createCompiler ( ) . compileModuleSync (
694- await createModule ( [
695- {
696- provide : APP_INITIALIZER ,
697- useValue : ( ) => {
698- throw 'Test' ;
699- } ,
700- multi : true ,
690+ const moduleType = await createModule ( [
691+ {
692+ provide : APP_INITIALIZER ,
693+ useValue : ( ) => {
694+ throw 'Test' ;
701695 } ,
702- ] ) ,
703- ) ;
696+ multi : true ,
697+ } ,
698+ ] ) ;
699+ const moduleFactory = await compileNgModuleFactory ( defaultPlatform . injector , { } , moduleType ) ;
704700 expect ( ( ) => defaultPlatform . bootstrapModuleFactory ( moduleFactory ) ) . toThrow ( 'Test' ) ;
705701 // Error rethrown will be seen by the exception handler since it's after
706702 // construction.
707703 expect ( mockConsole . res [ 0 ] . join ( '#' ) ) . toEqual ( 'ERROR#Test' ) ;
708704 } ) ) ;
709705
710706 it ( 'should rethrow promise errors even if the exceptionHandler is not rethrowing' , waitForAsync ( async ( ) => {
711- const compilerFactory : CompilerFactory = defaultPlatform . injector . get ( CompilerFactory , null ) ! ;
712- const moduleFactory = compilerFactory
713- . createCompiler ( )
714- . compileModuleSync (
715- await createModule ( [
716- { provide : APP_INITIALIZER , useValue : ( ) => Promise . reject ( 'Test' ) , multi : true } ,
717- ] ) ,
718- ) ;
707+ const moduleType = await createModule ( [
708+ { provide : APP_INITIALIZER , useValue : ( ) => Promise . reject ( 'Test' ) , multi : true } ,
709+ ] ) ;
710+ const moduleFactory = await compileNgModuleFactory ( defaultPlatform . injector , { } , moduleType ) ;
719711 defaultPlatform . bootstrapModuleFactory ( moduleFactory ) . then (
720712 ( ) => expect ( false ) . toBe ( true ) ,
721713 ( e ) => {
0 commit comments