PatrickJS / angular-hmr

:fire: Angular Hot Module Replacement for Hot Module Reloading
https://patrickjs.com
Apache License 2.0
506 stars 45 forks source link

Component selector is removed from index.html on hot reload #21

Closed ddbradshaw closed 8 years ago

ddbradshaw commented 8 years ago

For the life of I can't figure out why this is happening. Making a change to a component or css triggers the hot reload as expected, but during the reload lifecycle, my index.html app element is deleted from the body.

Component: screen shot 2016-08-24 at 9 44 39 pm

HTML Before reload: screen shot 2016-08-24 at 9 38 18 pm

HTML After reload: screen shot 2016-08-24 at 9 38 31 pm

This causes the following error to be thrown: screen shot 2016-08-24 at 9 39 27 pm

ddbradshaw commented 8 years ago

So, it is important to implement the hmr lifecycle hooks in the app module. Specifically, the following is required in the AppModule:

hmrOnDestroy(store)

I had left this out because I wasn't trying to maintain state, overlooking the fact that the createNewHosts method is called within this destroy method. CreateNewHosts creates a new psuedo app element prior to the deletion of the old app element.