mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
feat(module-loader): add preloadModules config option, set to false
set nav/basic to preload modules
This commit is contained in:
@@ -17,7 +17,7 @@ import { MyCmpTest2 } from '../pages/first-page/my-component-two';
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
IonicModule.forRoot(E2EApp, { swipeBackEnabled: true }, {
|
||||
IonicModule.forRoot(E2EApp, { swipeBackEnabled: true, preloadModules: true }, {
|
||||
links: [
|
||||
{ name: 'first-page', component: FirstPage },
|
||||
{ name: 'another-page', loadChildren: '../pages/another-page/another-page.module#AnotherPageModule' },
|
||||
|
||||
@@ -591,7 +591,7 @@ export class IonicModule {
|
||||
{ provide: APP_INITIALIZER, useFactory: registerModeConfigs, deps: [ Config ], multi: true },
|
||||
{ provide: APP_INITIALIZER, useFactory: setupProvideEvents, deps: [ Platform, DomController ], multi: true },
|
||||
{ provide: APP_INITIALIZER, useFactory: setupTapClick, deps: [ Config, Platform, DomController, App, NgZone, GestureController ], multi: true },
|
||||
{ provide: APP_INITIALIZER, useFactory: setupPreloading, deps: [ DeepLinkConfigToken, ModuleLoader ], multi: true },
|
||||
{ provide: APP_INITIALIZER, useFactory: setupPreloading, deps: [ Config, DeepLinkConfigToken, ModuleLoader ], multi: true },
|
||||
|
||||
// useClass
|
||||
// { provide: HAMMER_GESTURE_CONFIG, useClass: IonicGestureConfig },
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ComponentFactoryResolver, Injectable, Injector, NgModuleFactory, OpaqueToken, Type } from '@angular/core';
|
||||
import { Config } from '../config/config';
|
||||
import { DeepLinkConfig } from '../navigation/nav-util';
|
||||
import { NgModuleLoader } from './ng-module-loader';
|
||||
|
||||
@@ -75,11 +76,13 @@ export interface LoadedModule {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export function setupPreloading(deepLinkConfig: DeepLinkConfig, moduleLoader: ModuleLoader) {
|
||||
export function setupPreloading(config: Config, deepLinkConfig: DeepLinkConfig, moduleLoader: ModuleLoader) {
|
||||
return function() {
|
||||
const linksToLoad = deepLinkConfig.links.filter(link => !!link.loadChildren);
|
||||
for (const link of linksToLoad) {
|
||||
moduleLoader.load(link.loadChildren);
|
||||
if (config.getBoolean('preloadModules')) {
|
||||
const linksToLoad = deepLinkConfig.links.filter(link => !!link.loadChildren);
|
||||
for (const link of linksToLoad) {
|
||||
moduleLoader.load(link.loadChildren);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user