2

We have an Anguar Application (v 15.2.9) that utilize Module federation (v 15.0.0) to acheive MFE architecture. Now we need to apply Server Side Rendering (SSR) (v 15.2.1) and we followed the steps that mentioned in Adding Angular Universal to an existing Module Federation project ( https://github.com/angular-architects/module-federation-plugin/blob/main/libs/mf/README.md#trying-it-out). The first step work fine by disable asynchronous bootstrapping temporarily and in the second setp we excute the following command

ng add @nguniversal/common --project yourProject

But the following error appear

Collection "C:\POC\MFESSR\node_modules\@nguniversal\common\schematics\collection.json" cannot be resolved.

We have try different way to apply the steps that mentioned in the article but we get the same error even with a new application that doesn't have Module Federation.

s.alhaj
  • 141
  • 2
  • 11
  • I think you need `@nguniversal/express-engine`. What backend stack are you using? ASP.NET Core? – Pieterjan Aug 28 '23 at 05:53
  • @Pieterjan yes we are using ASP.Net core in the backend, express-engine will not work with Module Federation – s.alhaj Aug 28 '23 at 06:08
  • 1
    There are no schematics for [`@nguniversal/common`](https://github.com/angular/universal/tree/main/modules/common), which there are for [`@nguniversal/express-engine`](https://github.com/angular/universal/tree/main/modules/express-engine/schematics) – Pieterjan Aug 28 '23 at 11:22
  • Just did [these steps](https://github.com/angular-architects/module-federation-plugin/blob/main/libs/mf/README.md#adding-angular-universal-before-adding-module-federation) which seem to be working fine, except for the `@nguniversal/common` schematic which obviously doesn't exist. I replaced it in the command with `@nguniversal/express-engine` – Pieterjan Aug 28 '23 at 11:36
  • Hi @Pieterjan we replaced @ngguniversal/common with @nguniversal/express-engine and now SSR working fine, but we face another issue with router-outlet the content not shown in view page source and display as the following Could you please advise? – s.alhaj Aug 29 '23 at 13:59
  • In Visual Studio check the Output window. There should be **ERROR**s explaining what went wrong during SSR. – Pieterjan Aug 29 '23 at 15:48
  • Also, prevent sending webrequests during SSR. Most live environments don't allow those ajax calls anyway. Use [`OnSupplyData`](https://github.com/MintPlayer/MintPlayer.AspNetCore.SpaServices/blob/master/Demo/Demo.Web/Services/DemoSpaPrerenderingService.cs#L38) for this – Pieterjan Aug 29 '23 at 15:53
  • Have you been applied Component level (Partial) SSR instead of applying SSR to the entire application with Angular 15 @Pieterjan – s.alhaj Aug 31 '23 at 13:23

0 Answers0