File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed
qwik-city/src/runtime/src Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @builder.io/qwik ' : patch
3
+ ' @builder.io/qwik-city ' : patch
4
+ ---
5
+
6
+ PATCH: Keeping the service worker components now properly unregisters them.
Original file line number Diff line number Diff line change 2
2
3
3
( ( ) => {
4
4
if ( 'serviceWorker' in navigator ) {
5
- navigator . serviceWorker . register ( '__url' ) . catch ( ( e ) => console . error ( e ) ) ;
5
+ navigator . serviceWorker . getRegistrations ( ) . then ( ( regs ) => {
6
+ for ( const reg of regs ) {
7
+ const url = '__url' . split ( '/' ) . pop ( ) ;
8
+ if ( reg . active ?. scriptURL . endsWith ( url || 'service-worker.js' ) ) {
9
+ reg . unregister ( ) . catch ( console . error ) ;
10
+ }
11
+ }
12
+ } ) ;
6
13
} else {
7
14
// eslint-disable-next-line no-console
8
15
console . log ( 'Service worker not supported in this browser.' ) ;
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ export const PrefetchServiceWorker = (opts: {
42
42
// the file 'qwik-prefetch-service-worker.js' is not located in /build/
43
43
resolvedOpts . path = baseUrl + resolvedOpts . path ;
44
44
}
45
- let code = PREFETCH_CODE . replace ( "' _URL_'" , JSON . stringify ( resolvedOpts . path ) ) ;
45
+ let code = PREFETCH_CODE . replace ( '" _URL_"' , JSON . stringify ( resolvedOpts . path . split ( '/' ) . pop ( ) ) ) ;
46
46
if ( ! isDev ) {
47
47
// consecutive spaces are indentation
48
48
code = code . replaceAll ( / \s \s + / gm, '' ) ;
You can’t perform that action at this time.
0 commit comments