File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22import { CacheableResponsePlugin } from "workbox-cacheable-response" ;
33import { cacheNames } from "workbox-core" ;
44import { ExpirationPlugin } from "workbox-expiration" ;
5+
56import {
67 registerRoute ,
78 setCatchHandler ,
@@ -12,7 +13,6 @@ import {
1213 NetworkOnly ,
1314 StaleWhileRevalidate ,
1415} from "workbox-strategies" ;
15- /* eslint-enable import/no-extraneous-dependencies */
1616
1717const cacheName = cacheNames . runtime ;
1818
@@ -25,13 +25,21 @@ const otherManifest = [
2525 url : "/app-shell/index.html" ,
2626 } ,
2727] ;
28- const manifestURLs = [ ...manifest , ...otherManifest ] . map ( ( entry ) => {
29- const url = new URL ( entry . url , self . location ) ;
30- return url . href ;
31- } ) ;
28+ const manifestURLs = [
29+ ...new Set (
30+ [ ...manifest , ...otherManifest ] . map ( ( entry ) => {
31+ const url = new URL ( entry . url , self . location ) ;
32+ return url . href ;
33+ } ) ,
34+ ) ,
35+ ] ;
3236self . addEventListener ( "install" , ( event ) => {
3337 event . waitUntil (
34- caches . open ( cacheName ) . then ( ( cache ) => cache . addAll ( manifestURLs ) ) ,
38+ ( async ( ) => {
39+ const cache = await caches . open ( cacheName ) ;
40+
41+ await Promise . allSettled ( manifestURLs . map ( ( url ) => cache . add ( url ) ) ) ;
42+ } ) ( ) ,
3543 ) ;
3644} ) ;
3745
You can’t perform that action at this time.
0 commit comments