1 import { enableProdMode } from '@angular/core'
2 import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
4 import { AppModule } from './app/app.module'
5 import { environment } from './environments/environment'
7 import { hmrBootstrap } from './hmr'
9 if (environment.production) {
13 const bootstrap = () => platformBrowserDynamic()
14 .bootstrapModule(AppModule)
15 .then(bootstrapModule => {
16 // TODO: Remove when https://github.com/angular/angular-cli/issues/8779 is fixed?
17 if ('serviceWorker' in navigator && environment.production) {
18 navigator.serviceWorker.register('/ngsw-worker.js')
19 .catch(err => console.error('Cannot register service worker.', err))
22 return bootstrapModule
29 if (environment.hmr) {
30 if (module[ 'hot' ]) {
31 hmrBootstrap(module, bootstrap)
33 console.error('HMR is not enabled for webpack-dev-server!')
34 console.log('Are you using the --hmr flag for ng serve?')