1 import { enableProdMode, TRANSLATIONS, TRANSLATIONS_FORMAT } 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'
8 import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils'
9 import { buildFileLocale } from '../../shared'
11 let providers: any[] = []
12 if (environment.production) {
16 // Template translation, should be in the bootstrap step
17 if (isOnDevLocale()) {
18 const locale = buildFileLocale(getDevLocale())
19 const translations = require(`raw-loader!./locale/angular.${locale}.xlf`)
22 { provide: TRANSLATIONS, useValue: translations },
23 { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' }
27 const bootstrap = () => platformBrowserDynamic()
28 .bootstrapModule(AppModule, { providers })
29 .then(bootstrapModule => {
30 // TODO: Uncomment and remove unregistration when https://github.com/angular/angular/issues/21191 is fixed
31 // TODO: Remove when https://github.com/angular/angular-cli/issues/8779 is fixed?
32 // if ('serviceWorker' in navigator && environment.production) {
33 // navigator.serviceWorker.register('/ngsw-worker.js')
34 // .catch(err => console.error('Cannot register service worker.', err))
37 if (navigator.serviceWorker && typeof navigator.serviceWorker.getRegistrations === 'function') {
38 navigator.serviceWorker.getRegistrations()
39 .then(registrations => {
40 for (const registration of registrations) {
41 registration.unregister()
46 return bootstrapModule
53 if (environment.hmr) {
54 if (module[ 'hot' ]) {
55 hmrBootstrap(module, bootstrap)
57 console.error('HMR is not enabled for webpack-dev-server!')
58 console.log('Are you using the --hmr flag for ng serve?')