mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(module-loader): null references
This commit is contained in:
@@ -75,24 +75,26 @@ export interface LoadedModule {
|
||||
* @hidden
|
||||
*/
|
||||
export function setupPreloadingImplementation(config: Config, deepLinkConfig: DeepLinkConfig, moduleLoader: ModuleLoader): Promise<any> {
|
||||
if (config.getBoolean('preloadModules') && deepLinkConfig && deepLinkConfig.links) {
|
||||
const linksToLoad = deepLinkConfig.links.filter(link => !!link.loadChildren && link.priority !== 'off');
|
||||
|
||||
// Load the high priority modules first
|
||||
const highPriorityPromises = linksToLoad.filter(link => link.priority === 'high')
|
||||
.map(link => moduleLoader.load(link.loadChildren));
|
||||
|
||||
return Promise.all(highPriorityPromises).then(() => {
|
||||
// Load the low priority modules after the high priority are done
|
||||
const lowPriorityPromises = linksToLoad.filter(link => link.priority === 'low')
|
||||
.map(link => moduleLoader.load(link.loadChildren));
|
||||
return Promise.all(lowPriorityPromises);
|
||||
}).catch(err => {
|
||||
console.error(err.message);
|
||||
});
|
||||
} else {
|
||||
if (!deepLinkConfig || !deepLinkConfig.links || !config.getBoolean('preloadModules')) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
const linksToLoad = deepLinkConfig.links.filter(link => !!link.loadChildren && link.priority !== 'off');
|
||||
|
||||
// Load the high priority modules first
|
||||
const highPriorityPromises = linksToLoad
|
||||
.filter(link => link.priority === 'high')
|
||||
.map(link => moduleLoader.load(link.loadChildren));
|
||||
|
||||
return Promise.all(highPriorityPromises).then(() => {
|
||||
// Load the low priority modules after the high priority are done
|
||||
const lowPriorityPromises = linksToLoad
|
||||
.filter(link => link.priority === 'low')
|
||||
.map(link => moduleLoader.load(link.loadChildren));
|
||||
|
||||
return Promise.all(lowPriorityPromises);
|
||||
}).catch(err => {
|
||||
console.error(err.message);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user