SwOptions
Type. Configuration for service worker file generation.
Table of contents
Category
Type
Type import
tsimport type { sw } from "valyrian.js/node";
type SwOptions = NonNullable<Parameters<typeof sw>[1]>;Public signature
tsinterface SwOptions {
version?: string;
name?: string;
/** @deprecated Use criticalUrls instead */
urls?: string[];
criticalUrls?: string[];
optionalUrls?: string[];
debug?: boolean;
logFetch?: boolean;
offlinePage?: string;
}Type usage
SwOptions is the option shape accepted by sw(file, options). criticalUrls block worker installation when precaching fails, while optionalUrls are cached without blocking installation.
Defaults
tsversion: "1"
name: "Valyrian.js"
criticalUrls: options.criticalUrls ?? options.urls ?? ["/"]
optionalUrls: []
debug: false
logFetch: false
offlinePage: "/offline.html"Result
sw(...) returns void and writes the generated service worker to file. urls remains a deprecated fallback for criticalUrls.