question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Angular CLI wiki: HMR docs are out of date

See original GitHub issue

šŸ“š Docs or angular.io bug report

Description

Angular’s HMR (hot module replacement) docs are old and the steps don’t work anymore with @angularclass/hmr. https://github.com/angular/angular-cli/wiki/stories-configure-hmr


I spent a lot of time to get HMR to work based on the official Angular docs but it seems like these steps don’t work anymore. Not sure if Webpack has changed its API or @angularclass/hmr but the current steps in the official Angular docs don’t work anymore and the new steps that are documented in the original @angularclass/hmr docs work pretty well.

These 2 comments explain the simplest solution to get HMR to work with the latest Angular, Webpack and @angularclass/hmr: https://github.com/PatrickJS/angular-hmr/issues/81#issuecomment-449999297 https://github.com/PatrickJS/angular-hmr/issues/81#issuecomment-450028896

Simplest working solution (written by @Epono), anyone can clone and run it: https://github.com/Epono/angular-7-hmr

šŸ”¬ Minimal Reproduction

Just follow the steps in the official Angular docs on a new Angular project ng new test-app and it won’t work.

What’s the affected URL?**

https://github.com/angular/angular-cli/wiki/stories-configure-hmr

Reproduction Steps**

Just follow the steps in the official Angular docs on any new Angular project ng new test-app and it won’t work.

Expected vs Actual Behavior**

Expected: When a source file changes Webpack’s HMR picks up the changes and communicates it to the browser. Ideally it should refresh part of the page but at least it should display the fact of change in the console.

Actual: When the page is loaded in a browser (with ng serve --configuration hmr and a source file is changed (and saved) Webpack doesn’t do anything, it doesn’t load any new file over the network and it doesn’t display any change in the browser console, there’s no error in the browser console or the terminal.

šŸŒ Your Environment

Any new Angular install (ng new test-hmr-project)

Browser info

This isn’t a browser specific issue

Anything else relevant?

Probably caused by updated Webpack API or updated @angularclass/hmr API which isn’t reflected in the old (Aug 2, 2018) official Angular docs

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:13
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

7reactions
Splaktarcommented, May 30, 2020

Note that the wiki’s source (which isn’t in sync with the actual wiki) is found here: https://github.com/angular/angular-cli/blob/master/docs/documentation/stories/configure-hmr.md

Also note that that source has the following:

Documentation below is deprecated and we no longer accept PRs to improve this. The new documentation is available here.

Also please note that the Angular CLI GitHub Wiki is no longer the ā€œofficial Angular docsā€ for the Angular CLI as mentioned on the wiki landing page:

NOTE: this documentation is for Angular CLI 6. For Angular CLI Version 7 go here and 1.x go here instead.

And finally, it should be noted that there are no HMR docs for Angular version 7.

It would be helpful, as there is lots of interest, for someone to write a blog post that could later be turned into a PR to the official docs.

3reactions
Prinsncommented, Aug 14, 2019

Also, hopefully the docs make it clear how to use HMR with Lazy Loading.

If Angular 8 is going to push dynamic importing, as well as Lazy Loading and not make it clear how to put it all together, that’d be extremely lackluster.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HMR is not updating the view with Angular CLI - Stack Overflow
I am badly stuck with it. Following are my configurations according to the the HMR Story on Angular CLI wiki: angular.json
Read more >
The State of HMR in Angular - JavaScript in Plain English
It is a Webpack feature that updates changed modules without reloading the whole page. Angular 11 made it easy to use HMR by...
Read more >
How to configure Webpack 4 with Angular 7: a complete guide
The Angular CLI makes it easy to create an application that already works, right out of the box. It is a great tool,...
Read more >
Angular 6 Tutorial: New Features with New Power - Toptal
Angular 6 Tutorial: New Features with New Power. Angular 6 is out! The most outstanding changes are in its CLI and how services...
Read more >
Hot Module Replacement - webpack
Vue Loader: This loader supports HMR for vue components out of the box. Elm Hot webpack Loader: Supports HMR for the Elm programming...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found