localize-router icon indicating copy to clipboard operation
localize-router copied to clipboard

Lazy loaded component is not bootstrapping

Open vytautas-pranskunas- opened this issue 5 years ago • 4 comments

I am trying to do routes localization however home component is not bootstrapping on hard refresh also if i any route and do hard refresh get an error - No matches found. But if i click on any link in app.component that uses translated urls they are working. I have clones DEMO project and made home also lazy loaded and it works fine. Can someone help to understand why this might happen?

I have posted this question on Stackoverflow but there is no localize-router tag so I am re-posting it here https://stackoverflow.com/questions/54672738/localize-router-not-bootstrapping-component-on-refresh

vytautas-pranskunas- avatar Feb 13 '19 14:02 vytautas-pranskunas-

I was able to solve this issue and seems like this is not working with initialNavigation: 'enabled' on Router. And this is needed to prevent flickering with SSR.

Also i have an error on SSR: Error: Cannot find module './components/home/home.module.ngfactory' - how this can be solved?

vytautas-pranskunas- avatar Feb 14 '19 09:02 vytautas-pranskunas-

@vytautas-pranskunas- I solved this issue.

Our error was on the imports order on app-routing.module. The Router must be the first import, before LocalizeRouter

@NgModule({
  imports: [
    RouterModule.forRoot(appRoutes), <---------------- FIRST
    LocalizeRouterModule.forRoot(appRoutes)
  ],
  exports: [
    RouterModule, <---------------- FIRST
    LocalizeRouterModule
  ]
})

I don't know exactly if it's relevant on the forChild imports and exports but make sense follow the same order.

NOTE: We have SSR implemented

rafa-suagu avatar Feb 26 '19 11:02 rafa-suagu

@rafa-as We have import and export for parent app-routing.module, but it's doesn't change anything. Doesn't work.

qubiack avatar Apr 03 '19 14:04 qubiack

@vytautas-pranskunas- It's an SSR error. Do you use @nguniversal/module-map-ngfactory-loader ? This module change "lazy-load" to "simple load" only on server-side.

gilsdav avatar Jun 10 '19 19:06 gilsdav