Update workbox-build in / from 3.0.0-alpha.2 to 3.0.0 #30
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Dependencies.io has updated
workbox-build
(a npm dependency in/
) from "3.0.0-alpha.2" to "3.0.0".3.0.0
Overview of Workbox V3
Workbox v3 has been focused on reducing the size of the library, while lowering the friction for usage. This has been accomplished thanks to a significant refactoring of the existing codebase. We believe the migration process for most users should be minimal, taking a few hours.
Developers are encouraged to view our documentation, including a migration guide for moving from either Workbox v2 or from
sw-precache
/sw-toolbox
to Workbox v3.Many thanks to beatrizdemiguelperez, raejin, goldhand for contributing code for the v3 release, and to all the members of the community who tested and gave feedback during our alpha and beta periods.
🥅 High-level Goals for v3
Minimize the size of Workbox
The size of the Workbox libraries has been reduced. Instead of opting everyone in to a monolithic bundle, only code for the features you use will be imported at runtime.
Workbox has official CDN support
We provide a Google Cloud Storage-based CDN of the Workbox runtime libraries, making it easier to get up and running with Workbox.
Improved webpack Plugin
workbox-webpack-plugin
integrates more closely with the webpack build process, allowing for a zero-config use case when you want to precache all the assets in the build pipeline.Achieving these goals, and cleaning up some aspects of the previous interface that felt awkward or led to antipatterns, required introducing a number of breaking changes in the v3 release.
Better Debugging and Logs
The debugging and logging experience has been vastly improved. Debug logs are enabled by default whenever Workbox is used from a
localhost
origin and all logging and assertions are stripped from the production builds🎉 New Functionality
workbox-build
globFollow
andglobStrict
added toworkbox-build
. This means symbolic links will be followed when searching for files and any errors discovered byglob
will now throw. (#1104)workbox-cli
--injectManifest
in theworkbox-cli
wizard. (#1171)workbox-precaching
workbox-precaching
supports two new configuration options,cleanUrls
andurlManipulation
. By defaultcleanUrls
is true and will append.html
to a reqest when looking for a precache hit (i.e./about
will check for/about.html
).urlManipulation
can be a function enabling you to express a mapping between the server-side URL and the underlying local file. (#1154)If a precached request is not in the cache, we fallback to the network. (#1302)
Precaching will store requests in a temporary cache on install and copy these requests to final cache during the activate step. (#1316)
The precaching IndexedDB name is now derived from the cache name - allowing multiple precaches on a single origin. (#1346)
workbox-strategies
workbox-webpack-plugin
Adds support for webpack v4, while retaining support for webpack v3. (#1275)
workbox-webpack-plugin
now supports{test, include, exclude}
-style filtering, providing an additional way of controlling which assets are included in the precache manifest. By default, assets matching/\.map$/
or/^manifest\.js(?:on)$/
are excluded. (#1149)Build Configuration
The following changes affect the behavior of all of our build tools (
workbox-build
,workbox-cli
,workbox-webpack-plugin
), which share a common set of configuration options.The
'fastest'
handler name was previously valid, and treated as an alias for'staleWhileRevalidate'
, when configuringruntimeCaching
. It's no longer valid, and developers should switch to using'staleWhileRevalidate'
directly. (Drop support for 'fastest' as alias for StaleWhileRevalidate in runtimeCaching config GoogleChrome/workbox#915)Several
runtimeCaching.options
property names have been updated, and additional parameter validation is in place that will cause a build to fail if an invalid configuration is used. See the documentation forruntimeCaching
for a list of currently supported options. (Rethink valid runtimeCaching.options GoogleChrome/workbox#1096)A new
importWorkboxFrom
option can be used to determine where the Workbox libraries are read from: the CDN, locally, or from a custom bundle (when using webpack).workbox-background-sync
There are significant changes to the API surface in v3. Developers should consult the documentation for current guidance. (Changes to the workbox-background-sync API in v3 GoogleChrome/workbox#868)
The
maxRetentionTime
configuration option is now interpreted as a number of minutes, rather than milliseconds. (#1268)The tag name is now used when responding to a sync event. (#1280)
workbox-build
The default destination of a service worker for the CLI has changed from 'build/' to the location of the
globDirectory
(i.e. the directory searched for files to precache). (#1105)The
getFileManifestEntries()
function has been renamed togetManifest()
, and the promise returned now includes additional information about the URLs which are precached.The
generateFileManifest()
function has been removed. Developers are encouraged to callgetManifest()
instead, and use its response to write data to disk in the appropriate format.workbox-cache-expiration
The plugin API has stayed the same, however there are significant API changes impacting developers who use it as a standalone class. Consult the documentation for the updated API surface. (CacheExpiration Class - Breaking Changes GoogleChrome/workbox#920)
workbox-cache-expiration now throws an error if you attempt to expire entries on the default runtime cache (i.e. the shared cache used by all strategies by default). (#1079)
workbox-cli
The set of command line options, and the way of reading in stored configuration, have all changed. Developers should consult the documentation or run the CLI with the
--help
flag for guidance. (Changes to the workbox-cli interface in v3 GoogleChrome/workbox#865)Support for the
workbox-cli
alias for the binary script has been removed. The binary can now only be accessed asworkbox
. (Rename the workbox-cli binary to workbox GoogleChrome/workbox#730)workbox-google-analytics
workbox-background-sync
library, and therefore rely on the Background Sync API. (Offline Analytics V2 GoogleChrome/workbox#244)workbox-precaching
The
precache()
method previously performed both the cache modifications and set up routing to serve cached entries. Now,precache()
only modifies cache entries, and a new method,addRoute()
, has been exposed to register a route to serve those cached responses. Developers who want the previous, two-in-one functionality can switch to callingprecacheAndRoute()
. This enables more developer flexibility. (workbox-precaching - precache, addRoute, precacheAndRoute() GoogleChrome/workbox#886).workbox-broadcast-update
will no longer be automatically configured to announce cache updates for precached assets. To get this behavior, you can add the plugin manually. (Use BroadcastCacheUpdate from within Precaching? GoogleChrome/workbox#1073)workbox-routing
The
Router
will now evaluateRoute
s in a first-registered-wins order. This is the opposite order ofRoute
evaluation that was used in v2, where the last-registeredRoute
would be given precedence. (Change the order of Route evaluation in v3 GoogleChrome/workbox#845)The
ExpressRoute
class, and support for "Express-style" wildcards have been removed. This reduces the size ofworkbox-routing
considerably. Strings used as the first parameter toworkbox.routing.registerRoute()
will now be treated as exact matches. Wildcard or partial matches should be handled byRegExp
s—using anyRegExp
that matches against part or all of the request URL can trigger a route. (Treat registerRoute('/foo/:bar', ...) as exact match in v3 GoogleChrome/workbox#1012)The
addFetchListener()
helper method of theRouter
class has been removed. Developers can either add their ownfetch
handler explicitly, or use the interface provided byworkbox.routing
, which will implicitly create afetch
handler for them. (Router.addFetchListener() deprecated—document new behavior GoogleChrome/workbox#914)The
registerRoutes()
andunregisterRoutes()
methods were removed. The versions of those methods that operate on a singleRoute
were not changed, and developers who need to register or unregister multiple routes at once should make a series of calls toregisterRoute()
orunregisterRoute()
instead. (Remove Router.registerRoutes()/unregisterRoutes() methods GoogleChrome/workbox#856)workbox-strategies (formerly know as workbox-runtime-caching)
The
workbox-runtime-caching
module is now officially known asworkbox-strategies
, and has been published onnpm
under its new name. (workbox-runtime-caching renamed to workbox-strategies GoogleChrome/workbox#1045)The syntax for specifying plugins when configuring a strategy has changed. Each plugin needs to be explicitly listed in the
plugins
property of the strategy's configuration. (workbox-strategies will "auto" import cachable-response and broadcast-cache-update GoogleChrome/workbox#1071)Defining a strategy that applies to the default cache name and which uses cache expiration is no longer supported. When configuring cache expiration, you must also configure a specific cache name. (
cacheExpiration
on theruntime
cache - should we prevent? GoogleChrome/workbox#1014)The
cacheWillMatch
lifecycle method has been renamed tocachedResponseWillBeUsed
. This should not be a visible change for developers unless they wrote their own plugins that reacted tocacheWillMatch
. (Rename cacheWillMatch lifecycle method GoogleChrome/workbox#713)workbox-sw
The
handleFetch
option has been removed. (Drop support for WorkboxSW's handleFetch? GoogleChrome/workbox#1002)skipWaiting
andclientsClaim
are no longer options passed to theWorkboxSW
constructor. Instead, they have been changed to methods of the same name that could be called on theworkbox
namespace. (workbox-sw skipWaiting() && clients.claim() options to methods GoogleChrome/workbox#853)workbox-webpack-plugin