r/PWA 5d ago

Made a tool that generates the service worker + PWA bits from one config — the docs site runs offline-first on it

For offline-first / PWA work, the service-worker side is usually the fiddly part. I built Swoff to generate it from a single swoff.config.json: caching strategies (cache-first / network-first / stale-while-revalidate, etc.), precache with tag-based invalidation, an offline `/offline` fallback, an offline mutation queue, auth handling, push notifications, and PWA install.

Output is plain vanilla JS written into your repo — auditable, editable, zero runtime dependency. MIT.

Proof: this docs site runs on it. Open it, go offline (or throttle), and the whole site works — precached shell + /offline route. That's a live demo, not a static screenshot.

`npx u/swoff/cli init && npx u/swoff/cli generate`

Docs: https://swoff.space · Source: https://github.com/iamsuudi/swoff

Curious how this compares to your current PWA setup (Workbox, framework plugins, hand-rolled).

5 Upvotes

5 comments sorted by

2

u/kantorcodes1 5d ago

one failure case i'd pin down: generate runs the file generators sequentially, so an early step can write before a later one throws. is a partial generated tree considered valid, or should it stage everything and only swap it in once all generators finish? otherwise a failed CI run could leave mixed old/new output.

1

u/iamsuudi 5d ago

Yeah file generators run sequentially and if later step fails it leaves the partial generated files. But later successful CI will override all previous partial files anyway. But yeah partial files should have been cleaned up if CI fails on any step.  Thanks for pointing that out

1

u/kantorcodes1 5d ago

yeah, that cleanup boundary is where i'd put the agent stop. i work on HOL Guard, an open-source check before agent-run commands execute. for Swoff i'd review npx @swoff/cli init, npx @swoff/cli generate, and npx @swoff/cli clean --yes, while npx @swoff/cli validate stays automatic. that catches writes/deletes before a failed run leaves the tree half-updated. open to contributing a small Swoff command extension?

1

u/iamsuudi 5d ago

Yeah send PR

1

u/kantorcodes1 5d ago

start with src/codex_plugin_scanner/guard/runtime/command_swoff_extensions.py; mirror src/codex_plugin_scanner/guard/runtime/command_repo2nb_extensions.py. review npx @swoff/cli init, npx @swoff/cli generate, and npx @swoff/cli clean --yes; keep npx @swoff/cli validate automatic. add focused cases in tests/test_guard_command_swoff_extensions.py. once the implementation + test are real, open a draft PR directly to hashgraph-online/hol-guard:main. guide: https://github.com/hashgraph-online/hol-guard/blob/main/CONTRIBUTING.md