UNPKG

1.02 kBMarkdownView Raw
1# Module Map NgFactory Loader
2
3This is a NgFactory Loader which uses a map of modules instead of resolving modules lazily.
4
5This 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
14const { provideModuleMap } = require('@nguniversal/module-map-ngfactory-loader');
15const { AppModuleNgFactory, LAZY_MODULE_MAP } = require('main.bundle.js');
16
17renderModuleFactory(AppModuleNgFactory, {
18 document: '<app-root></app-root>',
19 url: '/',
20 extraProviders: [
21 provideModuleMap(LAZY_MODULE_MAP)
22 ]
23})
24```
25
26Add `ModuleMapLoaderModule` to your server module
27
28```ts
29import {ModuleMapLoaderModule} from '@nguniversal/module-map-ngfactory-loader';
30
31@NgModule({
32 imports: [
33 AppModule,
34 ServerModule,
35 ModuleMapLoaderModule
36 ],
37 bootstrap: [AppComponent],
38})
39export class AppServerModule {}
40```
\No newline at end of file