From 744067d2119364a2036b9137f3db33ea11347c4b Mon Sep 17 00:00:00 2001 From: ayoayco Date: Sat, 17 Aug 2024 21:35:36 +0200 Subject: [PATCH] chore: use mjs for sw --- astro.config.mjs | 2 +- src/{sw.ts => sw.mjs} | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) rename src/{sw.ts => sw.mjs} (97%) diff --git a/astro.config.mjs b/astro.config.mjs index da412ad..8d118f6 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -17,7 +17,7 @@ export default defineConfig({ mdx(), sitemap(), serviceWorker({ - path: "./src/sw.ts", + path: "./src/sw.mjs", assetCachePrefix: 'cozy-reader', assetCacheVersionID: VERSION, logAssets: true, diff --git a/src/sw.ts b/src/sw.mjs similarity index 97% rename from src/sw.ts rename to src/sw.mjs index 0346960..7f4c1f9 100644 --- a/src/sw.ts +++ b/src/sw.mjs @@ -4,7 +4,7 @@ import { logInfo } from './utils/logger' * -- find usage in `astro.config.mjs` integrations * @see https://ayco.io/n/@ayco/astro-sw */ -const cacheName = `${__prefix ?? 'app'}-v${__version ?? '000'}` +const cacheName = `${__prefix ?? 'app'}-v${__version + '-' + Date.now()}` const forceLogging = false; const addResourcesToCache = async (resources) => { @@ -113,9 +113,7 @@ self.addEventListener('activate', (event) => { self.addEventListener('install', (event) => { logInfo('installing service worker...', { force: forceLogging, context: 'cozy-sw' }) event.waitUntil( - addResourcesToCache([ - ...(__assets ?? []) - ]) + addResourcesToCache(__assets ?? []) ); self.skipWaiting(); // activate updated SW });