Skip to content

Component flickering when SSR and CMS Components lazy loading is enabled #20431

Description

@Frezzu

I found a bug related to SSR and lazy loading of CMS Components.

The bug looks like flickering of CMS components which is loaded via importing standalone component. When I import the same component via featureModules lazy loading it does not flicker.

I suppose the flickering is happening because SSR renders lazy component on the backend and later on the browser it is recreated but there is a time when the slot is cleared and import of lazy component is just scheduled so it didn't fetched yet. The featureModules resolves modules and cms components a lot earlier, I think at guard lvl.

 LoginLogoutComponent: {
      component: () =>
        import('@app/shared/features/auth/components/login-logout/login-logout.component').then(
          (m) => m.LoginLogoutComponent,
        ),
    },

vs

// config
featureModules: {
  LoginLogoutModule: {
    cmsComponents: ['LoginLogoutComponent'],
      module: () =>
      import('@app/shared/features/auth/components/login-logout/login-logout.module').then(
        (m) => m.LoginLogoutModule,
      ),
  },
},

// other file
@NgModule({
  imports: [LoginLogoutComponent],
  providers: [
    provideConfig({
      cmsComponents: {
        LoginLogoutComponent: {
          component: LoginLogoutComponent,
        },
      },
    }),
  ],
})
export class LoginLogoutModule {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions