This is an example implementation of a service-worker written in Rust and ran using wasm-bindgen and some utility functions for working with the worker. This allows for usage of service workers in a browser context with a minimal amount of JavaScript.
The worker
crate contains a service worker that will listen to messages and log them to the console.
The loader
crate contains functions which can be used to register a service worker with the browser.
You can follow wasm-bindgen's Without a Bundler
example to see how to run these in the browser.
There are nix flake packages for each of these components that can help deduce the build steps. See flake-parts/cargo.nix
to see how they are built.