mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-24 02:30:13 +00:00
In Angular2Spa, fix HMR with 2.4.6 and relax version dependency to allow arbitrary 2.x again. Fixes #643
This commit is contained in:
@@ -3,11 +3,18 @@ import { enableProdMode } from '@angular/core';
|
||||
import { platformUniversalDynamic } from 'angular2-universal';
|
||||
import { AppModule } from './app/app.module';
|
||||
import 'bootstrap';
|
||||
const rootElemTagName = 'app'; // Update this if you change your root component selector
|
||||
|
||||
// Enable either Hot Module Reloading or production mode
|
||||
if (module['hot']) {
|
||||
module['hot'].accept();
|
||||
module['hot'].dispose(() => { platform.destroy(); });
|
||||
module['hot'].dispose(() => {
|
||||
// Before restarting the app, we create a new root element and dispose the old one
|
||||
const oldRootElem = document.querySelector(rootElemTagName);
|
||||
const newRootElem = document.createElement(rootElemTagName);
|
||||
oldRootElem.parentNode.insertBefore(newRootElem, oldRootElem);
|
||||
platform.destroy();
|
||||
});
|
||||
} else {
|
||||
enableProdMode();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user