@@ -15,12 +15,14 @@ import {
1515 Compiler ,
1616 CompilerFactory ,
1717 Component ,
18+ effect ,
1819 EnvironmentInjector ,
1920 InjectionToken ,
2021 LOCALE_ID ,
2122 NgModule ,
2223 NgZone ,
2324 PlatformRef ,
25+ ProviderToken ,
2426 provideZoneChangeDetection ,
2527 RendererFactory2 ,
2628 TemplateRef ,
@@ -46,7 +48,6 @@ import {ApplicationRef} from '../src/application/application_ref';
4648import { NoopNgZone } from '../src/zone/ng_zone' ;
4749import { ComponentFixtureNoNgZone , inject , TestBed , waitForAsync , withModule } from '../testing' ;
4850import { take } from 'rxjs/operators' ;
49- import { compileNgModuleFactory } from '../src/application/application_ngmodule_factory_compiler' ;
5051
5152let serverPlatformModule : Promise < Type < ServerModule > > | null = null ;
5253if ( isNode ) {
@@ -660,38 +661,45 @@ describe('bootstrap', () => {
660661 initializerDone = true ;
661662 } , 1 ) ;
662663
663- const moduleType = await createModule ( [
664- { provide : APP_INITIALIZER , useValue : ( ) => promise , multi : true } ,
665- ] ) ;
666- const moduleFactory = await compileNgModuleFactory ( defaultPlatform . injector , { } , moduleType ) ;
667-
664+ const compilerFactory : CompilerFactory = defaultPlatform . injector . get ( CompilerFactory , null ) ! ;
665+ const moduleFactory = compilerFactory
666+ . createCompiler ( )
667+ . compileModuleSync (
668+ await createModule ( [ { provide : APP_INITIALIZER , useValue : ( ) => promise , multi : true } ] ) ,
669+ ) ;
668670 defaultPlatform . bootstrapModuleFactory ( moduleFactory ) . then ( ( _ ) => {
669671 expect ( initializerDone ) . toBe ( true ) ;
670672 } ) ;
671673 } ) ) ;
672674
673675 it ( 'should rethrow sync errors even if the exceptionHandler is not rethrowing' , waitForAsync ( async ( ) => {
674- const moduleType = await createModule ( [
675- {
676- provide : APP_INITIALIZER ,
677- useValue : ( ) => {
678- throw 'Test' ;
676+ const compilerFactory : CompilerFactory = defaultPlatform . injector . get ( CompilerFactory , null ) ! ;
677+ const moduleFactory = compilerFactory . createCompiler ( ) . compileModuleSync (
678+ await createModule ( [
679+ {
680+ provide : APP_INITIALIZER ,
681+ useValue : ( ) => {
682+ throw 'Test' ;
683+ } ,
684+ multi : true ,
679685 } ,
680- multi : true ,
681- } ,
682- ] ) ;
683- const moduleFactory = await compileNgModuleFactory ( defaultPlatform . injector , { } , moduleType ) ;
686+ ] ) ,
687+ ) ;
684688 expect ( ( ) => defaultPlatform . bootstrapModuleFactory ( moduleFactory ) ) . toThrow ( 'Test' ) ;
685689 // Error rethrown will be seen by the exception handler since it's after
686690 // construction.
687691 expect ( mockConsole . res [ 0 ] . join ( '#' ) ) . toEqual ( 'ERROR#Test' ) ;
688692 } ) ) ;
689693
690694 it ( 'should rethrow promise errors even if the exceptionHandler is not rethrowing' , waitForAsync ( async ( ) => {
691- const moduleType = await createModule ( [
692- { provide : APP_INITIALIZER , useValue : ( ) => Promise . reject ( 'Test' ) , multi : true } ,
693- ] ) ;
694- const moduleFactory = await compileNgModuleFactory ( defaultPlatform . injector , { } , moduleType ) ;
695+ const compilerFactory : CompilerFactory = defaultPlatform . injector . get ( CompilerFactory , null ) ! ;
696+ const moduleFactory = compilerFactory
697+ . createCompiler ( )
698+ . compileModuleSync (
699+ await createModule ( [
700+ { provide : APP_INITIALIZER , useValue : ( ) => Promise . reject ( 'Test' ) , multi : true } ,
701+ ] ) ,
702+ ) ;
695703 defaultPlatform . bootstrapModuleFactory ( moduleFactory ) . then (
696704 ( ) => expect ( false ) . toBe ( true ) ,
697705 ( e ) => {
0 commit comments