1 import { ApplicationRef, enableProdMode } from '@angular/core'
2 import { enableDebugTools } from '@angular/platform-browser'
3 import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
4 import { AppModule } from './app/app.module'
5 import { environment } from './environments/environment'
7 if (environment.production) {
11 const bootstrap = () => platformBrowserDynamic()
12 .bootstrapModule(AppModule)
13 .then(bootstrapModule => {
14 // TODO: Uncomment and remove unregistration when https://github.com/angular/angular/issues/21191 is fixed
15 // TODO: Remove when https://github.com/angular/angular-cli/issues/8779 is fixed?
16 // if ('serviceWorker' in navigator && environment.production) {
17 // navigator.serviceWorker.register('/ngsw-worker.js')
18 // .catch(err => console.error('Cannot register service worker.', err))
21 if (navigator.serviceWorker && typeof navigator.serviceWorker.getRegistrations === 'function') {
22 navigator.serviceWorker.getRegistrations()
23 .then(registrations => {
24 for (const registration of registrations) {
25 registration.unregister()
30 if (!environment.production) {
31 const applicationRef = bootstrapModule.injector.get(ApplicationRef)
32 const componentRef = applicationRef.components[0]
34 // allows to run `ng.profiler.timeChangeDetection();`
35 enableDebugTools(componentRef)
38 return bootstrapModule