| Name | Modified | Size | Downloads / Week |
|---|---|---|---|
| Parent folder | |||
| workbox-v4.0.0-beta.2.tar.gz | 2019-01-29 | 105.5 kB | |
| workbox-v4.0.0-beta.2.zip | 2019-01-29 | 163.7 kB | |
| README.md | 2019-01-29 | 3.7 kB | |
| Workbox v4.0.0-beta.2 source code.tar.gz | 2019-01-29 | 589.3 kB | |
| Workbox v4.0.0-beta.2 source code.zip | 2019-01-29 | 936.9 kB | |
| Totals: 5 Items | 1.8 MB | 0 | |
The latest beta release of Workbox v4 includes the following developer-visible changes, in addition to all the changes from the previous pre-releases.
🎉 What's New?
workbox-window
-
The
Workboxconstructor function signature has changed to accept an optionalscriptVersionoption. To support this new option (and other future options) the constructor now accepts a single object argument [#1861].:::js // Old way new Workbox(scriptURL, registerOptions);
// New way new Workbox({ scriptUrl, scriptVersion, registerOptions, });
-
The properties
.activeand.controllinghave been added to theWorkboxclass. These are promises which will resolve as soon asWorkboxhas a reference to a service working in the corresponding state (active or controlling) with a matchingscriptURL(and optionallyscriptVersion, if used). These are similar to thenavigator.serviceWorker.readypromise, but when usingscriptVersionyou can be sure they won't resolve until the correct version of the script is active/controlling [#1861]. -
Workboxevent listeners are now always called with anEvent-like object (i.e. they have a.type,.targetproperties), to more closely match how native event listeners work. In the future when all browsers support contructableEventTarget, these will be nativeEventobjects [#1861].:::js // Old way myWorkbox.addEventListener('activated', (sw) => { // Do something with
sw. });// New way myWorkbox.addEventListener('activated', (event) => { // The activated service worker is at
event.sw. // And the underlying event that triggered this is atevent.originalEvent. }); -
The
controllingevent is now dispatched prior to theactivatedevent, which correctly matches the ordering of when thecontrollerchangeandstatechangeevents fire in the service worker lifecycle. [#1861]
workbox-routing
- The
workbox.routing.Router#addCacheListener()method has updated the format off messages it can receive from the window to cache. Previously it would accept an array of URL strings, now it can also accept an array of URL strings or arrays in the form of[url, requestInit]. This is useful if you need to override the default request mode [#1851]
Build tools
- Support for a new
booleanconfiguration option,cleanupOutdatedCaches, has been added to theGenerateSWmode of all of the build tools. It defaults tofalse. When set totrue, a call toworkbox.precaching.cleanupOutdatedCaches()will automatically be added to your generated service worker, which will in turn delete any out-of-date precaches no longer used by Workbox. Workbox v4 introduced a breaking change to the precache format, so developers upgrading from Workbox v3 or earlier might find this useful. [#1863]
🐛 What's Fixed?
workbox-webpack-plugin
- In addition to
swSrcbeing a file on file system, it can now be a webpack generated asset as well. This allows users to compile their service worker with webpack and then give it as a source toinject-manifestplugin. [#1763]
workbox-core
- Don't set fetchOptions when request.mode is 'navigate', to work around an issue that could lead to failed navigations. [#1862]