]>
Commit | Line | Data |
---|---|---|
e309822b | 1 | import { enableProdMode, TRANSLATIONS, TRANSLATIONS_FORMAT } from '@angular/core' |
b6827820 | 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic' |
63c4db6d | 3 | |
b6827820 C |
4 | import { AppModule } from './app/app.module' |
5 | import { environment } from './environments/environment' | |
63c4db6d | 6 | |
77d07d69 | 7 | import { hmrBootstrap } from './hmr' |
74b7c6d4 | 8 | import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils' |
77d07d69 | 9 | |
e309822b | 10 | let providers = [] |
63c4db6d | 11 | if (environment.production) { |
b6827820 | 12 | enableProdMode() |
63c4db6d C |
13 | } |
14 | ||
74b7c6d4 C |
15 | // Template translation, should be in the bootstrap step |
16 | if (isOnDevLocale()) { | |
17 | const locale = getDevLocale() | |
18 | const translations = require(`raw-loader!./locale/target/angular_${locale}.xml`) | |
e309822b C |
19 | |
20 | providers = [ | |
21 | { provide: TRANSLATIONS, useValue: translations }, | |
22 | { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' } | |
23 | ] | |
24 | } | |
25 | ||
77d07d69 | 26 | const bootstrap = () => platformBrowserDynamic() |
e309822b | 27 | .bootstrapModule(AppModule, { providers }) |
78967fca | 28 | .then(bootstrapModule => { |
fed95155 | 29 | // TODO: Uncomment and remove unregistration when https://github.com/angular/angular/issues/21191 is fixed |
78967fca | 30 | // TODO: Remove when https://github.com/angular/angular-cli/issues/8779 is fixed? |
fed95155 C |
31 | // if ('serviceWorker' in navigator && environment.production) { |
32 | // navigator.serviceWorker.register('/ngsw-worker.js') | |
33 | // .catch(err => console.error('Cannot register service worker.', err)) | |
34 | // } | |
35 | ||
73e09f27 C |
36 | if (navigator.serviceWorker) { |
37 | navigator.serviceWorker.getRegistrations() | |
38 | .then(registrations => { | |
39 | for (const registration of registrations) { | |
40 | registration.unregister() | |
41 | } | |
42 | }) | |
43 | } | |
78967fca C |
44 | |
45 | return bootstrapModule | |
46 | }) | |
47 | .catch(err => { | |
48 | console.error(err) | |
49 | return null | |
50 | }) | |
77d07d69 C |
51 | |
52 | if (environment.hmr) { | |
53 | if (module[ 'hot' ]) { | |
54 | hmrBootstrap(module, bootstrap) | |
55 | } else { | |
56 | console.error('HMR is not enabled for webpack-dev-server!') | |
57 | console.log('Are you using the --hmr flag for ng serve?') | |
58 | } | |
59 | } else { | |
60 | bootstrap() | |
61 | } |