Angular 9 SSR - where to set global['window'] (using domino)?
Solved, thanks to this comment https://github.com/angular/universal/issues/1678#issuecomment-627031128
The key is to have line
import { AppServerModule } from './src/main.server';
after the definition of global['window']
Beware the autoformatters in your editor, which usually put the import lines on top of the file automatically :)
I put it below the imports and above the app() method
import { ngExpressEngine } from '@nguniversal/express-engine';import * as express from 'express';import { join } from 'path';import { AppServerModule } from './src/main.server';import { APP_BASE_HREF } from '@angular/common';import { existsSync, readFileSync } from 'fs';import * as domino from 'domino';import * as core from 'express-serve-static-core';const template = join('browser', 'index.html');const win = domino.createWindow(template);global['window'] = win;global['document'] = win.document;// The Express app is exported so that it can be used by serverless Functions.export function app(): core.Express {