-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding app-shell breaks down lazy loading on server-side #9202
Comments
As I understand, using App Shell have a meaning only if I don't use server-side rendering. If I use Universal-app for server-side rendering, my web-server returns not blank page, so using App Shell is redundant. But I need some kind of App Shell for PWA, so I have to provide some URL with App Shell by myself without using Please correct me, if I missed something. |
Hi, I have investigated this issue to a degree. I also cannot find any way of using app-shells with Universal... Sorry i wrote a novel, feel free to skip down to the solutions Conflict:
Solutions:
@krivochenko Your solution should work, if you need an example, let me know @hansl @Brocco Should we pursue providing a dummy moule map here? It would look like const html = await renderModuleFactory(AppServerModuleNgFactory, {
url: options.url,
document: index,
extraProviders: [
provideModuleMap({})
]
}); |
@Brocco you mentioned that app shell feature in CLI is not documented when we spoke in ng-atl. Can you tell me what is the process to get that documented? Thanks. |
Any update on this? |
I looked into this and the problem is that when using the To fix this one need to add the following in providers: [{
provide: NgModuleFactoryLoader,
useClass: ModuleMapNgFactoryLoader
}], That said, this only works with the latest packages of the dependencies. Created an example repo here: https://github.com/alan-agius4/universal-lazy-loading-app-shell //cc @vikerman |
@alan-agius4 - The provider should be used at the platform providers level and not the ServerAppModule https://github.com/angular/universal-starter/blob/master/server.ts#L28 |
@vikerman that does work as well. Thanks for your input |
At the moment, there is no clear explaination how to make an app-shell work togather with SSR and lazy loading. See for more context angular/angular-cli#9202
… ssr (#646) At the moment, there is no clear explaination how to make an app-shell work togather with SSR and lazy loading. See for more context angular/angular-cli#9202
@alan-agius4 your solution does not work for me. I keep getting the error: Cannot find module 'app/pages/contacts/contacts.module.ngfactory' |
I solve my problem doing the following: ng run my-app:app-shell:production
sed -i -e "s/RouterModule.forRoot/\\/\\/ RouterModule.forRoot/g" path/to/app.server.module.ts
ng run my-app:server
sed -i -e "s/\\/\\/ RouterModule.forRoot/RouterModule.forRoot/g" path/to/app.server.module.ts |
Hi @csbenjamin, please note that this issue is closed. If this issue is still happening even with changes stated in the documentation, please open a new issue with a minimal reproduction and a step by step guide. A good way to make a minimal repro is to create a new app via This might be related to your directory structure so its really important to get an accurate repro to diagnose this. |
@alan-agius4 Thanks for the reply. Here is the new issue |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Versions
Repro steps
Observed behavior
Server-side rendering doesn't work (in source code of page I see only router-outlet). In console of server I get error:
Desired behavior
I expect server-side rendering work without errors.
Mention any other details that might be useful (optional)
I created simple repo for reproduction of issue by following steps:
Thanks for help
The text was updated successfully, but these errors were encountered: