wintercg / runtime-keys

https://runtime-keys.proposal.wintercg.org
30 stars 10 forks source link

Service worker runtime environment #13

Open mfulton26 opened 2 months ago

mfulton26 commented 2 months ago

Can browser service worker runtime be included?

Hono can run in Node, Deno, Bun, Cloudflare Workers, Pages, and can also run in a service worker to power an offline web app.

I'd like to see more things target/support service workers too (e.g. Next.js, Deno Fresh, and HonoX could all be made to work in various runtime environments and could then easily be ran in a service worker).

pi0 commented 2 months ago

It seems an interesting idea for service-worker to be considered as an standard runtime. Especially because SW is a "vendor-agnostic" variant of edge runtimes.

One point to mention though, SW support at least used to be inconsistent between browser vendors like top-level await behavior between Chrome and FF. I hope it is better now but only mentioning because we might also consider browser vendors for runtime-key specifically like chrome-sw.


For reference, Nitro also allows building servers for service-worker targets (for Nuxt, SolidStart, Analog, or any other fw) offline. This target was under the experimental flag for 3+ years and supporting virtually any server to run on SW not sure if anyone used it in the real-world scenarios though, i think merits more weight in the standard side for me at least than offline usage.