Skip to content

Commit caa0752

Browse files
committed
improvement: do not lazy load the features module
There's no need to do that and having to download another js file is not helping
1 parent 732f848 commit caa0752

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/app/app-routing.module.ts

+12-7
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,26 @@ import {
77
} from '@angular/router';
88

99
import { RuntimeEnvironmentService } from 'app/core/runtime-environment.service';
10+
import { FeaturesModule } from 'app/features/features.module';
1011
import { environment } from 'environments/environment';
1112

12-
// if you don't want to lazy load the features module,
13-
// simply put the loadFeaturesModule as value of loadChildren
14-
// import { FeaturesModule } from './features/features.module';
13+
// if you want to lazy load the features module,
14+
// 1 - remove the `import { FeaturesModule } from ...`;
15+
// 2 - remove the loadFeaturesModule function
1516

16-
// export function loadFeaturesModule() {
17-
// return FeaturesModule;
18-
// }
17+
// we cannot use shorthand like that:
18+
// loadChildren: () => FeaturesModule
19+
// to be AOT compliant, we need to create
20+
// a named function and export the module
21+
export function loadFeaturesModule() {
22+
return FeaturesModule;
23+
}
1924

2025
const routes: Routes = [
2126
{
2227
path: '',
2328
canActivate: [RuntimeEnvironmentService],
24-
loadChildren: 'app/features/features.module#FeaturesModule',
29+
loadChildren: loadFeaturesModule,
2530
},
2631
];
2732

0 commit comments

Comments
 (0)