]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/main.ts
Translated using Weblate (Spanish)
[github/Chocobozzz/PeerTube.git] / client / src / main.ts
CommitLineData
361dcebc 1import { enableProdMode } from '@angular/core'
b6827820 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()
361dcebc 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
c7ca4c8b 23 if (navigator.serviceWorker && typeof navigator.serviceWorker.getRegistrations === 'function') {
73e09f27 24 navigator.serviceWorker.getRegistrations()
361dcebc
C
25 .then(registrations => {
26 for (const registration of registrations) {
27 registration.unregister()
28 }
29 })
73e09f27 30 }
78967fca
C
31
32 return bootstrapModule
33 })
34 .catch(err => {
35 console.error(err)
36 return null
37 })
77d07d69
C
38
39if (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}