Skip to content
This repository was archived by the owner on Oct 14, 2024. It is now read-only.

Commit a8f8cdf

Browse files
alan-agius4CaerusKaru
authored andcommitted
fix: add optional section to make appshell work with lazy-loading and ssr (#646)
At the moment, there is no clear explaination how to make an app-shell work togather with SSR and lazy loading. See for more context angular/angular-cli#9202
1 parent dc64b0a commit a8f8cdf

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

server.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import 'zone.js/dist/zone-node';
22
import 'reflect-metadata';
3-
import {enableProdMode} from '@angular/core';
3+
import { enableProdMode } from '@angular/core';
4+
45
// Express Engine
5-
import {ngExpressEngine} from '@nguniversal/express-engine';
6+
import { ngExpressEngine } from '@nguniversal/express-engine';
67
// Import module map for lazy loading
7-
import {provideModuleMap} from '@nguniversal/module-map-ngfactory-loader';
8+
import { provideModuleMap } from '@nguniversal/module-map-ngfactory-loader';
89

910
import * as express from 'express';
10-
import {join} from 'path';
11+
import { join } from 'path';
1112

1213
// Faster server renders w/ Prod mode (dev mode never needed)
1314
enableProdMode();
@@ -19,13 +20,23 @@ const PORT = process.env.PORT || 4000;
1920
const DIST_FOLDER = join(process.cwd(), 'dist');
2021

2122
// * NOTE :: leave this as require() since this file is built Dynamically from webpack
22-
const {AppServerModuleNgFactory, LAZY_MODULE_MAP} = require('./server/main');
23+
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./server/main');
2324

2425
// Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
2526
app.engine('html', ngExpressEngine({
2627
bootstrap: AppServerModuleNgFactory,
2728
providers: [
28-
provideModuleMap(LAZY_MODULE_MAP)
29+
provideModuleMap(LAZY_MODULE_MAP),
30+
// In case you want to use an AppShell with SSR and Lazy loading
31+
// you'd need to uncomment the below. (see: https://github.com/angular/angular-cli/issues/9202)
32+
// {
33+
// provide: NgModuleFactoryLoader,
34+
// useClass: ModuleMapNgFactoryLoader,
35+
// deps: [
36+
// Compiler,
37+
// MODULE_MAP
38+
// ],
39+
// },
2940
]
3041
}));
3142

0 commit comments

Comments
 (0)