]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/main.ts
Throttle infinite scroller
[github/Chocobozzz/PeerTube.git] / client / src / main.ts
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: Remove when https://github.com/angular/angular-cli/issues/8779 is fixed?
17 if ('serviceWorker' in navigator && environment.production) {
18 navigator.serviceWorker.register('/ngsw-worker.js')
19 .catch(err => console.error('Cannot register service worker.', err))
20 }
21
22 return bootstrapModule
23 })
24 .catch(err => {
25 console.error(err)
26 return null
27 })
28
29 if (environment.hmr) {
30 if (module[ 'hot' ]) {
31 hmrBootstrap(module, bootstrap)
32 } else {
33 console.error('HMR is not enabled for webpack-dev-server!')
34 console.log('Are you using the --hmr flag for ng serve?')
35 }
36 } else {
37 bootstrap()
38 }