@@ -10,9 +10,9 @@ export class EggModuleLoader {
1010 this . moduleReferences = moduleReferences ;
1111 }
1212
13- private buildAppGraph ( loaderCache : Map < string , Loader > ) {
13+ private static buildAppGraph ( loaderCache : Map < string , Loader > , moduleReferences : readonly ModuleReference [ ] ) {
1414 const appGraph = new AppGraph ( ) ;
15- for ( const moduleConfig of this . moduleReferences ) {
15+ for ( const moduleConfig of moduleReferences ) {
1616 const modulePath = moduleConfig . path ;
1717 const moduleNode = new ModuleNode ( moduleConfig ) ;
1818 const loader = LoaderFactory . createLoader ( modulePath , EggLoadUnitType . MODULE ) ;
@@ -27,10 +27,10 @@ export class EggModuleLoader {
2727 return appGraph ;
2828 }
2929
30- async load ( ) : Promise < LoadUnit [ ] > {
30+ private static async load ( moduleReferences : readonly ModuleReference [ ] ) : Promise < LoadUnit [ ] > {
3131 const loadUnits : LoadUnit [ ] = [ ] ;
3232 const loaderCache = new Map < string , Loader > ( ) ;
33- const appGraph = this . buildAppGraph ( loaderCache ) ;
33+ const appGraph = EggModuleLoader . buildAppGraph ( loaderCache , moduleReferences ) ;
3434 appGraph . sort ( ) ;
3535 const moduleConfigList = appGraph . moduleConfigList ;
3636 for ( const moduleConfig of moduleConfigList ) {
@@ -40,6 +40,16 @@ export class EggModuleLoader {
4040 loadUnits . push ( loadUnit ) ;
4141 }
4242 return loadUnits ;
43- // return loadUnits;
43+ }
44+
45+ async load ( ) : Promise < LoadUnit [ ] > {
46+ return await EggModuleLoader . load ( this . moduleReferences ) ;
47+ }
48+
49+ static async preLoad ( moduleReferences : readonly ModuleReference [ ] ) : Promise < void > {
50+ const loads = await EggModuleLoader . load ( moduleReferences ) ;
51+ for ( const load of loads ) {
52+ await load . preLoad ?.( ) ;
53+ }
4454 }
4555}
0 commit comments