]>
Commit | Line | Data |
---|---|---|
1 | import { enableProdMode } from '@angular/core' | |
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic' | |
3 | ||
4 | import { AppModule } from './app/app.module' | |
5 | import { environment } from './environments/environment' | |
6 | ||
7 | import { hmrBootstrap } from './hmr' | |
8 | ||
9 | if (environment.production) { | |
10 | enableProdMode() | |
11 | } | |
12 | ||
13 | const bootstrap = () => platformBrowserDynamic() | |
14 | .bootstrapModule(AppModule) | |
15 | .then(bootstrapModule => { | |
16 | // TODO: Uncomment and remove unregistration when https://github.com/angular/angular/issues/21191 is fixed | |
17 | // TODO: Remove when https://github.com/angular/angular-cli/issues/8779 is fixed? | |
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 | ||
23 | navigator.serviceWorker.getRegistrations().then(registrations => { | |
24 | for (const registration of registrations) { | |
25 | registration.unregister() | |
26 | } | |
27 | }) | |
28 | ||
29 | return bootstrapModule | |
30 | }) | |
31 | .catch(err => { | |
32 | console.error(err) | |
33 | return null | |
34 | }) | |
35 | ||
36 | if (environment.hmr) { | |
37 | if (module[ 'hot' ]) { | |
38 | hmrBootstrap(module, bootstrap) | |
39 | } else { | |
40 | console.error('HMR is not enabled for webpack-dev-server!') | |
41 | console.log('Are you using the --hmr flag for ng serve?') | |
42 | } | |
43 | } else { | |
44 | bootstrap() | |
45 | } |