SSR Angular 8 application have lazy-load modules as undefined

The problem is that there are two copies of Angular in the older way of setting up Universal and it confuses the lazy loading system.

You can manually fix this issue by updating the following:

package.json

add --bundleDependencies all at the end of the value of build:client-and-server-bundles

server.ts

remove the following lines

import {enableProdMode} from '@angular/core';     
import {ngExpressEngine} from '@nguniversal/express-engine';  
import {provideModuleMap} from '@nguniversal/module-map-ngfactory-loader';
enableProdMode();
const {AppServerModuleNgFactory, LAZY_MODULE_MAP} = require('./dist/server/main');

then add

const {AppServerModuleNgFactory, LAZY_MODULE_MAP, ngExpressEngine, provideModuleMap} = require('./dist/server/main');

main.server.ts

add

export {ngExpressEngine} from '@nguniversal/express-engine';
export {provideModuleMap} from '@nguniversal/module-map-ngfactory-loader';

webpack.server.config.js

add

externals: {
 './dist/server/main': 'require("./server/main")'
}

Reference: fix lazy loading and bundleDependencies