1 | # Module Map NgFactory Loader
|
2 |
|
3 | This is a NgFactory Loader which uses a map of modules instead of resolving modules lazily.
|
4 |
|
5 | This is useful when executing in node because lazy loading serves no purpose
|
6 |
|
7 | ## Usage with `@angular/cli`
|
8 |
|
9 | `npm install @nguniversal/module-map-ngfactory-loader --save`
|
10 |
|
11 | `@angular/cli` will generate `LAZY_MODULE_MAP` in its main output bundle if you put app.platform = 'server'.
|
12 |
|
13 | ```ts
|
14 | const { provideModuleMap } = require('@nguniversal/module-map-ngfactory-loader');
|
15 | const { AppModuleNgFactory, LAZY_MODULE_MAP } = require('main.bundle.js');
|
16 |
|
17 | renderModuleFactory(AppModuleNgFactory, {
|
18 | document: '<app-root></app-root>',
|
19 | url: '/',
|
20 | extraProviders: [
|
21 | provideModuleMap(LAZY_MODULE_MAP)
|
22 | ]
|
23 | })
|
24 | ```
|
25 |
|
26 | Add `ModuleMapLoaderModule` to your server module
|
27 |
|
28 | ```ts
|
29 | import {ModuleMapLoaderModule} from '@nguniversal/module-map-ngfactory-loader';
|
30 |
|
31 | @NgModule({
|
32 | imports: [
|
33 | AppModule,
|
34 | ServerModule,
|
35 | ModuleMapLoaderModule
|
36 | ],
|
37 | bootstrap: [AppComponent],
|
38 | })
|
39 | export class AppServerModule {}
|
40 | ``` |
\ | No newline at end of file |