You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(qwik-city): custom service-worker.ts code is also being unregistered (#7872)
* fix: custom service-worker.ts code is also being unregistered
* chore: changeset
* fix: clientOutDir type issue
* Update .changeset/thin-horses-bake.md
Co-authored-by: Giorgio Boa <[email protected]>
* fix: also unregister when service-worker.ts is removed and delete cache in any case
* refactor: only check if service-worker.ts is removed to unregister
---------
Co-authored-by: Giorgio Boa <[email protected]>
FIX: Your service-worker.js won't be unregistered anymore if you added custom logic to it.
6
+
7
+
> Note: Qwik 1.14.0 and above now use `<link rel="modulepreload">` by default. If you didn't add custom service-worker logic, you should remove your service-worker.ts file(s) for the `ServiceWorkerRegister` Component to actually unregister the service-worker.js and delete its related cache. Make sure to keep the `ServiceWorkerRegister` Component in your app (without any service-worker.ts file) as long as you want to unregister the service-worker.js for your users.
"serviceWorker"in navigator&&navigator.serviceWorker.getRegistrations().then(r=>{for(const e of r){const c='__url'.split("/").pop();e.active?.scriptURL.endsWith(c||"service-worker.js")&&e.unregister().catch(console.error)}}),"caches"in window&&caches.keys().then(r=>{const e=r.find(c=>c.startsWith("QwikBuild"));e&&caches.delete(e).catch(console.error)}).catch(console.error)
31
25
`;
26
+
// Code in SW_UNREGISTER unregisters the service worker and deletes the cache; it is the minified version of the following:
0 commit comments