feat(examples)+test(e2e): counter service worker; bankai dev+prod in Chromium

The counter example gains a sw.js exercising bankai's injected-precache
build. e2e proves both bankai paths in real Chromium: the built app
serves, hydrates and runs with zero console errors and zero mismatch
warnings (and choo consumed window.initialState), and the dev server's
Vite-transformed virtual entry hydrates the same way.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014NgfSjHE11oFpoSnLVKLXd
This commit is contained in:
Bendik Aagaard Lynghaug
2026-09-08 19:32:37 +02:00
co-authored by Claude Fable 5
parent 7e08b585ac
commit 8b684a17d2
2 changed files with 100 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
/* global __BANKAI_ASSETS__ */
// Service worker built by `bankai build`: the precache list is injected
// at build time from the asset manifest (the choo-service-worker
// convention, manifest edition). Register it from your app with
// navigator.serviceWorker.register('/sw.js').
const CACHE = 'counter-v1'
const ASSETS = __BANKAI_ASSETS__
self.addEventListener('install', (event) => {
event.waitUntil(
caches.open(CACHE).then((cache) => cache.addAll(ASSETS))
)
})
self.addEventListener('activate', (event) => {
event.waitUntil(
caches.keys().then((keys) =>
Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))
)
)
})
self.addEventListener('fetch', (event) => {
event.respondWith(
caches.match(event.request).then((hit) => hit || fetch(event.request))
)
})