-
Notifications
You must be signed in to change notification settings - Fork 12k
lazy loaded module is not found when using ng serve until recompile is triggered #8162
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
Comments
When I build the application with ng build, this setup shows the error. So the bug here seems to be that ng serve removes it when rebuilding. (Or that the error is there in the first place, I am not quite sure about the expected behaviour here, if the later we should probably move this issue) |
Turns out this approach to handling routing does not work at all, for reasons I don't quite understand. So I am no longer affected by this issue (I use canLoad now). Regardless, ng serve should behave consistently, that is consistently show the error. |
I think what you were experiencing is related to #7305 actually. It seems that environments aren't persisted correctly across rebuilds: #7305 (comment) If you don't think that's the same thing let me know and I will reopen this one. |
I've the same issue. I don't think that's the same in #7305. Angular CLI: 1.5.2 @ angular/cli: 1.5.2 |
Interestingly, if you remove the if block around the route definition in the sample repo it works. i.e.
It appears to me that there must be something buggy about whatever analyzes your code for use of I stumbled on this problem when trying to make use of routing modules within my app. It is a somewhat larger app and, curiously, if I don't make use of routing modules and define my routes within the respective module itself it works fine on startup. If I don't and use routing modules and get the error and I add a change to a file then let it compile via the watcher it works fine. I can't seem to find it (if I'll do I'll post it here) but I found another github issue a few days ago while trying to troubleshoot this where people were reporting something along the same lines. Searching the repo
However, it also appears to be part of AoT which I am currently not using. In any case, I strongly recommend that this issue be reopened as @EnricoMazzu has had the issue and simply doing-
also exposes the problem. I will continue investigating and if I find the source of the problem I will look into submitting a pull request. I should also mention that I am using, at the time of this writing, the most current angular-cli version. |
Same problem here Angular CLI: 6.0.8 Package Version@angular-devkit/architect 0.6.8 |
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. |
Bug Report or Feature Request (mark with an
x
)Versions.
@angular/cli: 1.4.9
node: 6.11.0
os: linux x64
@angular/animations: 4.4.6
@angular/common: 4.4.6
@angular/compiler: 4.4.6
@angular/core: 4.4.6
@angular/forms: 4.4.6
@angular/http: 4.4.6
@angular/platform-browser: 4.4.6
@angular/platform-browser-dynamic: 4.4.6
@angular/router: 4.4.6
@angular/cli: 1.4.9
@angular/compiler-cli: 4.4.6
@angular/language-service: 4.4.6
typescript: 2.3.4
Ubuntu 16.04
Checked in Chrome
Repro steps.
The relevant part here is that the route using the sometimes module is only added if environment.production is falsy. This seems to cause the difference between the initial build in ng serve and later rebuilds.
The log given by the failure.
Desired functionality.
ng serve should produce the same result for the same code, regardless if it is the first compile or a recompile later.
Mention any other details that might be useful.
I will try and see if the error happens if I deploy the result of ng build to a simple webserver.
The text was updated successfully, but these errors were encountered: