]>
Commit | Line | Data |
---|---|---|
b6827820 C |
1 | import { enableProdMode } from '@angular/core' |
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 C |
7 | import { hmrBootstrap } from './hmr' |
8 | ||
63c4db6d | 9 | if (environment.production) { |
b6827820 | 10 | enableProdMode() |
63c4db6d C |
11 | } |
12 | ||
77d07d69 | 13 | const bootstrap = () => platformBrowserDynamic() |
b6827820 | 14 | .bootstrapModule(AppModule) |
78967fca | 15 | .then(bootstrapModule => { |
fed95155 | 16 | // TODO: Uncomment and remove unregistration when https://github.com/angular/angular/issues/21191 is fixed |
78967fca | 17 | // TODO: Remove when https://github.com/angular/angular-cli/issues/8779 is fixed? |
fed95155 C |
18 | // if ('serviceWorker' in navigator && environment.production) { |
19 | // navigator.serviceWorker.register('/ngsw-worker.js') | |
20 | // .catch(err => console.error('Cannot register service worker.', err)) | |
21 | // } | |
22 | ||
73e09f27 C |
23 | if (navigator.serviceWorker) { |
24 | navigator.serviceWorker.getRegistrations() | |
25 | .then(registrations => { | |
26 | for (const registration of registrations) { | |
27 | registration.unregister() | |
28 | } | |
29 | }) | |
30 | } | |
78967fca C |
31 | |
32 | return bootstrapModule | |
33 | }) | |
34 | .catch(err => { | |
35 | console.error(err) | |
36 | return null | |
37 | }) | |
77d07d69 C |
38 | |
39 | if (environment.hmr) { | |
40 | if (module[ 'hot' ]) { | |
41 | hmrBootstrap(module, bootstrap) | |
42 | } else { | |
43 | console.error('HMR is not enabled for webpack-dev-server!') | |
44 | console.log('Are you using the --hmr flag for ng serve?') | |
45 | } | |
46 | } else { | |
47 | bootstrap() | |
48 | } |