-
Notifications
You must be signed in to change notification settings - Fork 0
Eugene Lazutkin edited this page Aug 8, 2026
·
3 revisions
install(options) wires fetch, message, and activate listeners on the worker scope and returns {cacheTier, coalescer, bundle, hub}. The deployable worker is a few lines:
// sw.js — bundle this, then register the output with {type: 'module'}
import {install} from 'double-meh-sw/sw.js';
install({
version: '2026.07.04',
match: '/api/',
cache: {cacheName: 'app-shared'},
bundler: {url: '/bundle', match: '/api/'}
});A module service worker does not resolve bare specifiers: serving this file unbundled fails
registration outright. Ship the bundled output, or import by URL —
/node_modules/double-meh-sw/src/sw.js.
| Option | Default | Meaning |
|---|---|---|
scope |
globalThis |
The worker scope — injectable, which is how the whole suite runs on Node/Bun/Deno. |
version |
— | Reported over io:version and in the io:hello reply. |
match |
same-origin, non-navigation | Which GETs the worker handles at all: a URL prefix, RegExp, or predicate. |
cache |
{cacheName: 'io-shared'} |
Cache tier options. |
bundler |
off |
Bundle window options plus its own match for eligibility. |
fetch |
globalThis.fetch |
The upstream — injectable for tests and mocks. |
claim |
true |
clients.claim() on activate. |
Cache tier hit → bundle window (configured, matched, and the client did not announce a library — client-wins) → coalesced network. Non-GETs and unmatched requests are never touched.
Two rules shape everything:
- The respondWith decision is synchronous — only the matcher gates it; all async work happens after.
- Everything degrades to plain fetches — bundler trouble, missing parts, lone-request windows: the worker must be a no-op-degradable adornment. If it vanishes entirely (first visit, hard reload), the app is logically unchanged. The cache tier is held to the same rule: a read or write that throws — a quota error is the ordinary case — is a miss and a no-op, never a failed request. Only the network may fail a request.
See also: Messages, Cache tier.
Start
Modules
Project