From bc1f83664f42105f4cf36730812c657fa84a9272 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=BE=E3=81=A3=E3=81=A1=E3=82=83=E3=81=A6=E3=81=83?= =?UTF-8?q?=E3=83=BC=E3=80=82?= <56515516+mattyatea@users.noreply.github.com> Date: Fri, 12 Dec 2025 17:08:15 +0900 Subject: [PATCH] =?UTF-8?q?fix(sw):=20Service=20Worker=20Auto=20Preload?= =?UTF-8?q?=E3=82=92=E3=82=AA=E3=83=97=E3=83=88=E3=82=A2=E3=82=A6=E3=83=88?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=20(#16971)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Service Worker Auto Preloadをオプトアウトするように * TypeErrorを修正 * コメントを追記 --- packages/sw/src/sw.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/sw/src/sw.ts b/packages/sw/src/sw.ts index 21017f8241..2bccbb0542 100644 --- a/packages/sw/src/sw.ts +++ b/packages/sw/src/sw.ts @@ -59,8 +59,21 @@ async function offlineContentHTML() { return `${messages.title}
${messages.header}
v${_VERSION_}
`; } -globalThis.addEventListener('install', () => { - // ev.waitUntil(globalThis.skipWaiting()); +globalThis.addEventListener('install', (ev) => { + // 次の問題が発生するため、ServiceWorkerAutoPreload をオプトアウトする必要がある + // https://issues.chromium.org/issues/466790291 + if ('addRoutes' in ev) { + // doc: https://developer.mozilla.org/en-US/docs/Web/API/InstallEvent/addRoutes + // @ts-expect-error 実験的なAPIなので型定義がない + ev.addRoutes({ + condition: { + // doc: https://developer.mozilla.org/ja/docs/Web/API/URLPattern + // @ts-expect-error 実験的なAPIなので型定義がない + urlPattern: new URLPattern({}), + }, + source: 'fetch-event', + }); + } }); globalThis.addEventListener('activate', ev => {