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'
10 if (environment.production) {
14 if (environment.production === false && window.location.search === '?lang=fr') {
15 const translations = require(`raw-loader!./locale/target/messages_fr.xml`)
18 { provide: TRANSLATIONS, useValue: translations },
19 { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' }
23 const bootstrap = () => platformBrowserDynamic()
24 .bootstrapModule(AppModule, { providers })
25 .then(bootstrapModule => {
26 // TODO: Uncomment and remove unregistration when https://github.com/angular/angular/issues/21191 is fixed
27 // TODO: Remove when https://github.com/angular/angular-cli/issues/8779 is fixed?
28 // if ('serviceWorker' in navigator && environment.production) {
29 // navigator.serviceWorker.register('/ngsw-worker.js')
30 // .catch(err => console.error('Cannot register service worker.', err))
33 if (navigator.serviceWorker) {
34 navigator.serviceWorker.getRegistrations()
35 .then(registrations => {
36 for (const registration of registrations) {
37 registration.unregister()
42 return bootstrapModule
49 if (environment.hmr) {
50 if (module[ 'hot' ]) {
51 hmrBootstrap(module, bootstrap)
53 console.error('HMR is not enabled for webpack-dev-server!')
54 console.log('Are you using the --hmr flag for ng serve?')