Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

After upgrade to angular 5 components that are only part of browser route still being counted and produce errors #488

Closed
yosigolan opened this issue Nov 5, 2017 · 1 comment

Comments

@yosigolan
Copy link

yosigolan commented Nov 5, 2017

Hello.
i have a project with many modules and components. i am using lazy loaded modules in my project and for universal i am using the ModuleMapLoaderModule.
some of the routes in my project are relevant to seo and also users might navigate to them directly however some routes are user specific routes and therefore not relevant to seo. the routes which are user specific include complicated components with many 3rd parties which does not support angular universal so in my project i have different root modules for the server side and browser side (as shown here: "https://github.com/samvloeberghs/ng-universal-demo/tree/master/src/app") with different routes for each one of them. in the server module i only include the routes which are relevant to seo and for all other routes i display some general "please wait" route. the browser module include all routes off course.
this project works great in angular 4 how ever after upgrading to angular 5 suddenly i am receiving errors when i start the node server regarding the components which are not part of the server routes. i receive the "window is not defined" errors and so on from the 3rd parties. the error appears even before i navigate to the any route (as soon as i start the node server). it seems that when running the node server it tries to run or read all the components in the project and it encounter the problematic components.
i cant use the regular approach of isBrowser because i am using many 3rd parties and it will force me to make too many changes in the user specific components. since these components are not relevant to server i just want to ignore then i server side rendering.

is this is a change in angular 5 or that this is a bug (that components which are not relevant to server side rendering raise issues)?
is there a way to work as in angular 4 where these components are not relevant until the app is running in the browser?

Thanks Yosi

@yosigolan yosigolan changed the title After upgrade to angular 5 components that are only part of browser router still being counted and produce errors After upgrade to angular 5 components that are only part of browser route still being counted and produce errors Nov 5, 2017
@yosigolan
Copy link
Author

i opened it in the universal repo: angular/universal#838

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant