-
Notifications
You must be signed in to change notification settings - Fork 518
Angular-CLI-Based-Template: Lazy Loading doesnt work with SSR #1413
Comments
@SteveSandersonMS I have gone through the official guide for universal by Angular CLI team and also look at https://github.com/angular/universal-starter. The only difference I see is in the step 4 https://github.com/angular/angular-cli/wiki/stories-universal-rendering#step-4-setting-up-an-express-server-to-run-our-universal-bundles . |
Thanks for reporting this. I tracked it down. Here's the changes you need to make to fix it: dotnet/AspNetCore.Docs@de171ac |
Thank you so much @SteveSandersonMS for the awesome work :) |
@naveedahmed1, I'm having trouble with lazy loading the FetchDataModule with SSR RouterModule.forRoot([
{ path: '', component: HomeComponent, pathMatch: 'full' },
{ path: 'counter', loadChildren: './counter/counter.module#CounterModule' },
{ path: 'fetch-data', loadChildren: './fetch-data/fetch-data.module#FetchDataModule'}
], { useHash: false, enableTracing: false, initialNavigation: 'enabled' }) It works alright if I navigate to http://localhost:5000/fetch-data by clicking the nav menu. However I got error when I tied to hit http://localhost:5000/fetch-data directly: Apparently, the arguments from FetchDataComponent constructor was causing the trouble, could you please help? |
@SteveSandersonMS with new Angular CLI based template the Lazy Loading doesn't work when we enable SSR. The server log shows below error:
To reproduce this error
Convert the Counter section to Lazy Module
Update AppModule, remove Counter Component from Declarations array and update route for counter url.
I think the template is missing
ts-loader
Ref: https://github.com/angular/angular-cli/wiki/stories-universal-rendering#install-dependencies
And
webpack.server.config.js
https://github.com/angular/angular-cli/wiki/stories-universal-rendering#webpackserverconfigjs-root-project-level
The text was updated successfully, but these errors were encountered: