📎 Webclip
Release Workbox v5.0.0
Workbox v5 centers on local bundles instead of relying on the CDN, simplifies precache injection, and adds TypeScript definitions for browser APIs. It also expands precaching controls, adds helpers for reading precached responses, and updates routing and broadcast behavior.
Reading notes#
generateSWnow creates a local bundle with only the runtime methods actually used in the service worker, optionally imported from a separate file or inlined.InjectManifestnow runs the service worker source through webpack compilation, with optional webpack plugins applied throughwebpackPlugins.workbox-webpack-pluginno longer supportsgloboptions for precache entries; webpack assets are now the source of generated manifest entries.manifestTransformscan now modify any part of the precache manifest, including adding, removing, or changingrevisionandurlfields.- The precache manifest is now inlined into the top-level service worker file instead of being stored in a separate external JavaScript file.
injectManifestnow replaces theself.__WB_MANIFESTplaceholder instead of using a regular expression based replacement.- Browser-facing Workbox packages are now written in TypeScript, and npm publishes type definitions for those APIs.
- Build tools now support
additionalManifestEntriesfor adding precache entries such as versioned CDN URLs, with warnings for unversioned string entries. GenerateSWnow supportsimportScriptsViaChunks, which includes named webpack chunks in the generated service worker.- Precache entries can include optional
integritymetadata for thefetch()request used to populate the cache. workbox-windowaddsupdate()to trigger a manual service worker update check.- Navigation route options rename
blacklistandwhitelisttodenylistandallowlist. registerNavigationRoute()is replaced bycreateHandlerBoundToURL()plusNavigationRouteandregisterRoute()for the same app shell behavior.workbox-broadcast-updateaddsgeneratePayload()for customizing the message sent after a cached response changes.copyResponse()can clone a response while changing headers, status, or statusText.- When precaching bypasses the HTTP cache, Workbox now uses
cache: 'reload'on the request instead of adding__WB_REVISIONto the outgoing network request. - Development logging can now be disabled with the
__WB_DISABLE_DEV_LOGSglobal. matchPrecache()andcreateHandler()make manual access to precached assets easier.manifestTransformscallbacks are now awaited, andworkbox-buildandworkbox-clican useruntimeCachingwithout precaching configuration.- Breaking changes include removal of several old configuration options, renamed navigation options, package-specific plugin class names,
BroadcastChannelremoval inworkbox-broadcast-update, removal ofgenerateSWString, a higher Node minimum,makeRequest()removal in favor ofhandle(), and a webpack v4+ requirement forworkbox-webpack-plugin.
