@@ -15,13 +15,15 @@ import {
1515 Compiler ,
1616 CompilerFactory ,
1717 Component ,
18+ effect ,
1819 EnvironmentInjector ,
1920 InjectionToken ,
2021 Injector ,
2122 LOCALE_ID ,
2223 NgModule ,
2324 NgZone ,
2425 PlatformRef ,
26+ ProviderToken ,
2527 provideZoneChangeDetection ,
2628 RendererFactory2 ,
2729 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 ) {
@@ -676,38 +677,45 @@ describe('bootstrap', () => {
676677 initializerDone = true ;
677678 } , 1 ) ;
678679
679- const moduleType = await createModule ( [
680- { provide : APP_INITIALIZER , useValue : ( ) => promise , multi : true } ,
681- ] ) ;
682- const moduleFactory = await compileNgModuleFactory ( defaultPlatform . injector , { } , moduleType ) ;
683-
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+ ) ;
684686 defaultPlatform . bootstrapModuleFactory ( moduleFactory ) . then ( ( _ ) => {
685687 expect ( initializerDone ) . toBe ( true ) ;
686688 } ) ;
687689 } ) ) ;
688690
689691 it ( 'should rethrow sync errors even if the exceptionHandler is not rethrowing' , waitForAsync ( async ( ) => {
690- const moduleType = await createModule ( [
691- {
692- provide : APP_INITIALIZER ,
693- useValue : ( ) => {
694- throw 'Test' ;
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 ,
695701 } ,
696- multi : true ,
697- } ,
698- ] ) ;
699- const moduleFactory = await compileNgModuleFactory ( defaultPlatform . injector , { } , moduleType ) ;
702+ ] ) ,
703+ ) ;
700704 expect ( ( ) => defaultPlatform . bootstrapModuleFactory ( moduleFactory ) ) . toThrow ( 'Test' ) ;
701705 // Error rethrown will be seen by the exception handler since it's after
702706 // construction.
703707 expect ( mockConsole . res [ 0 ] . join ( '#' ) ) . toEqual ( 'ERROR#Test' ) ;
704708 } ) ) ;
705709
706710 it ( 'should rethrow promise errors even if the exceptionHandler is not rethrowing' , waitForAsync ( async ( ) => {
707- const moduleType = await createModule ( [
708- { provide : APP_INITIALIZER , useValue : ( ) => Promise . reject ( 'Test' ) , multi : true } ,
709- ] ) ;
710- const moduleFactory = await compileNgModuleFactory ( defaultPlatform . injector , { } , moduleType ) ;
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+ ) ;
711719 defaultPlatform . bootstrapModuleFactory ( moduleFactory ) . then (
712720 ( ) => expect ( false ) . toBe ( true ) ,
713721 ( e ) => {
0 commit comments