From 6460d0569ceccf5531a2ce10743a15ac07a6415f Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Fri, 18 Sep 2026 19:59:02 -0400 Subject: [PATCH] dev: register the dev service worker as an ES module so it actually loads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit vite-plugin-pwa's dev-sw.js imports workbox as a module; registering it as a classic script failed with 'script evaluation failed', leaving the dev client with no SW — authenticated media 401'd (broken images in every dev screenshot) and SW notification routing was untestable. Production sw.js is unaffected. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA --- src/index.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index 926408b19..f03746241 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -33,7 +33,13 @@ if ('serviceWorker' in navigator) { pushSessionToSW(session?.baseUrl, session?.accessToken); }; - navigator.serviceWorker.register(swUrl).then(sendSessionToSW); + // The dev worker is an ES module (it imports workbox), so it must be + // registered as one — otherwise "script evaluation failed" and the dev + // client has no SW: authenticated media 401s and notification clicks + // never route. Production sw.js is a classic bundled script. + navigator.serviceWorker + .register(swUrl, import.meta.env.MODE === 'production' ? undefined : { type: 'module' }) + .then(sendSessionToSW); navigator.serviceWorker.ready.then(sendSessionToSW); navigator.serviceWorker.addEventListener('message', (ev) => {