-
Notifications
You must be signed in to change notification settings - Fork 45
HMR / Angular CLI and lazy routes #42
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
@montella1507 most likely pre-enabled aot on latest cli, since my starter worked well with hmr and lazy load |
@antonybudianto7 it worked with thr same version of CLI, but after "part of time".. when i change anything in 80% of my code it must reload entire page... (when i change something in the specific part of my application, HMR works) Im not sure if i forgot something or not.. I have only 1x accept() in my code (i have HMR specific code only in hmr.ts and main.ts ( https://medium.com/@beeman/tutorial-enable-hrm-in-angular-cli-apps-1b0d13b80130#.jbftda8bb like here). Is there anything needed in every module? |
I followed the same tutorial actually, but since latest CLI release (beta22-1), it didn't work on lazy loaded components |
@antonybudianto7 ah.. so that may be the cause of the problems for me as well.. im in deadlock little bit :-)) So the only working solution is with beta22 (not 22-1) |
Hey @montella1507 and @antonybudianto7, I've written the tutorial and am encountering the same problem like you guys. I did not yet found a solution to get it working with angular-cli beta 24. I'll post it here if I find one. |
It appears that it was a user error in my case. The complete warning in my console was:
It appeared I had the |
I have the same problem with lazy loaded routes, though in my case, sometimes it says there is a hot reload but nothing actually happens and the other times it defaults to the error that @montella1507 faced
|
Is there any progress regarding this issue? |
I've figure out a workable solution(may be better). see here https://github.com/e-cloud/ngrx-store-hmr-integration |
Did anyone found a better way of handling HMR with lazy loading? |
@e-cloud's solution works pretty well for me. EXCEPT:
Edit: using |
Any updates? |
Please check out this example I've put together that shows how to reload lazy-loaded routes and lazy/manual-loaded components. It doesn't maintain component state, but has really helped our development team increase their speed of local development. |
Has any one have such experience - using @wags1999 solution, that HMR reloaded right lazy-module, but rendered HTML wasn't updated to new code? It works in an example, but not in my project. Cannot find a difference between two. |
Hi,
is it possible to use HMR with Lazy routes?
HMR works correctly if i change something in "normally" loaded routes (components).
but if i change something in Lazy loaded module, it will refresh the entire page with error:
HMR] Cannot apply update. Need to do a full reload!(anonymous function) @ dev-server.js:33ZoneDelegate.invoke @ zone.js:232Zone.run @ zone.js:114(anonymous function) @ zone.js:502ZoneDelegate.invokeTask @ zone.js:265Zone.runTask @ zone.js:154drainMicroTaskQueue @ zone.js:401 dev-server.js:34 [HMR] Error: A platform with a different configuration has been created. Please destroy it first. at assertPlatform (http://localhost:4200/vendor.bundle.js:27579:15) at http://localhost:4200/vendor.bundle.js:27564:16 at bootstrap (http://localhost:4200/main.bundle.js:273:132) at hmrBootstrap (http://localhost:4200/main.bundle.js:1091:5) at Object.<anonymous> (http://localhost:4200/main.bundle.js:277:90) at Object.494 (http://localhost:4200/main.bundle.js:288:30) at __webpack_require__ (http://localhost:4200/inline.bundle.js:686:30) at hotApply (http://localhost:4200/inline.bundle.js:613:14) at hotUpdateDownloaded (http://localhost:4200/inline.bundle.js:311:13) at hotAddUpdateChunk (http://localhost:4200/inline.bundle.js:291:13)(anonymous function) @ dev-server.js:34ZoneDelegate.invoke @ zone.js:232Zone.run @ zone.js:114(anonymous function) @ zone.js:502ZoneDelegate.invokeTask @ zone.js:265Zone.runTask @ zone.js:154drainMicroTaskQueue @ zone.js:401 dev-server.js:49[HMR] Waiting for update signal from WDS...
But strange is, it wont work if i change something in my "SharedModule" with shared components - across all modules (lazy loaded too)
if (!platform.injector.get(requiredToken, null)) { throw new Error('A platform with a different configuration has been created. Please destroy it first.'); }
it will drop (requiredToken is "Platform: browserDynamic")
I have solution from there:
https://medium.com/@beeman/tutorial-enable-hrm-in-angular-cli-apps-1b0d13b80130#.jbftda8bb
Thanks for your work.
The text was updated successfully, but these errors were encountered: