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
After upgrade to angular 5 components that are only part of browser route still being counted as server and produce errors #838
Comments
Hi, I am seeing the same behavior. Any news regarding this? |
This may be better suited for the main angular repo since it sounds like it’s a compiler issue. Either way, you’ll need to provide a more detailed minimal reproduction repo since the one you linked doesn’t adequately detail your issue. |
Thank you for your answer @CaerusKaru . |
Hey @CaerusKaru in order to reproduce the bug do as follows:
short explanation on whats happening: |
@yakirgot take a look at angular/angular-cli#8749 and see if it helps. |
Thanks @naveedahmed1 ! i will check it. |
Thanks to @naveedahmed1 i found the solution. Enjoy |
@yosigolan I've tried adding modules to the exclude section of tsconfig.server.json, however, the server build is ignoring the exclusion and I am still receiving 'Unexpected token import' error. I'm using Angular CLI version 1.7.3 and Angular version 5.2.4. Do you know if by excluding the module file (services.module.ts) the build process will also exclude all files referenced therein? Any ideas on what I'm doing wrong? I've tried every variation of pathing and globs for the target module to exclude. Thanks for your time. |
Hey @tomschreck . i cant tell. |
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. |
Note: for support questions, please use one of these channels: https://github.com/angular/universal/blob/master/CONTRIBUTING.md#question. This repository's issues are reserved for feature requests and bug reports. Also, Preboot has moved to https://github.com/angular/preboot - please make preboot-related issues there.
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?
The text was updated successfully, but these errors were encountered: