1 import { NgModuleRef, ApplicationRef } from '@angular/core'
2 import { createNewHosts } from '@angularclass/hmr'
4 export const hmrBootstrap = (module: any, bootstrap: () => Promise<NgModuleRef<any>>) => {
5 let ngModule: NgModuleRef<any>
8 .then(mod => ngModule = mod)
9 module.hot.dispose(() => {
10 const appRef: ApplicationRef = ngModule.injector.get(ApplicationRef)
11 const elements = appRef.components.map(c => c.location.nativeElement)
12 const makeVisible = createNewHosts(elements)