]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/main.ts
Fix player dispose exception
[github/Chocobozzz/PeerTube.git] / client / src / main.ts
CommitLineData
b6827820
C
1import { enableProdMode } from '@angular/core'
2import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
63c4db6d 3
b6827820
C
4import { AppModule } from './app/app.module'
5import { environment } from './environments/environment'
63c4db6d 6
77d07d69
C
7import { hmrBootstrap } from './hmr'
8
63c4db6d 9if (environment.production) {
b6827820 10 enableProdMode()
63c4db6d
C
11}
12
77d07d69 13const 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
23 navigator.serviceWorker.getRegistrations().then(registrations => {
24 for (const registration of registrations) {
25 registration.unregister()
26 }
27 })
78967fca
C
28
29 return bootstrapModule
30 })
31 .catch(err => {
32 console.error(err)
33 return null
34 })
77d07d69
C
35
36if (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}