I'm facing an issue with Angular Universal throwing:
ERROR ReferenceError: document is not defined
This is Fullcalendar module that is trying to access document on server side, which does not exist on server. What I would like to do is to follow the guideline from Angular Git hub, from https://github.com/angular/universal/blob/master/docs/gotchas.md, saying:
If you have a component provided by a third-party that is not Universal-compatible out of the box, you can create two separate modules for browser and server (the server module you should already have), in addition to your base app module. The base app module will contain all of your platform-agnostic code, the browser module will contain all of your browser-specific/server-incompatible code, and vice-versa for your server module. In order to avoid editing too much template code, you can create a no-op component to drop in for the library component
I have created browser module:
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { AppModule } from './app.module';
import { CalendarModule } from './calendar/calendar.module';
@NgModule({
imports: [
AppModule,
CalendarModule // <---- this module will include the code that must only run on the browser
],
bootstrap: [AppComponent]
})
export class AppBrowserModule { }
Now I do not know which other files I should amend in order to make:
- app.module.ts only platform agnostic code (shared module that can be imported to both server/browser modules)
- server.module.ts only server side code (that can be ssr'ed)
- browser.module.ts that include all the platform agnostic code and browser code (e.g. fullcalendar module