universal: Angular 15 SSR and Lazy-Loading module not loading state on server

What modules are related to this issue?

  • builders
  • common
  • express-engine

Is this a regression?

No

Description

Recently we started changing our architecture from Angular SSR to use SSR with Lazy Loading modules.

In the first versions the modules were all imported on our routes file.

A component, for instance, would load data from our API and if running at the server would add data to the transferState. At the browser, we would check if the state existed, if not, load from the backend.

Now our components are lazy-loaded in different modules:

  • App Module lazy-loads A module with A component
  • A Module lazy-loads B module with B component

before B component would load data as stated before (with transferState), but the behavior now is to load only on the client side.

Did we get it wrong that it would be possible to continue using server-side loading, or something was implemented wrongly?

🌍 Your Environment


Angular CLI: 15.0.4
Node: 18.12.1
Package Manager: npm 8.19.2
OS: darwin arm64

Angular: 15.0.4
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1500.4
@angular-devkit/build-angular   15.0.4
@angular-devkit/core            15.0.4
@angular-devkit/schematics      15.0.4
@angular/cdk                    15.0.3
@angular/material               15.0.3
@nguniversal/builders           15.0.0
@nguniversal/express-engine     15.0.0
@schematics/angular             15.0.4
rxjs                            7.8.0
typescript                      4.8.4

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16

Most upvoted comments

Let me take a look at this on Monday.

project. Are there any circumstances that make it not load the module for pre-rendering on server? It seems it never gets to the second level router

Typically misconfiguration of the router APP_BASE_HREF and/or incorrect request parameters