Migrate from Workbox v2 to v3

This guide is focused on breaking changes introduced in Workbox v3, with examples of what changes you'd need to make when upgrading from a Workbox v2 setup.

If you're currently using the legacy sw-precache/sw-toolbox combination, and are looking to transition to Workbox for the first time, here's a different migration guide which will help.

v3 Background

Workbox's v3 release represents a significant refactoring of the existing codebase. The overarching goals are:

  • Minimize the size of the Workbox. The amount of service worker runtime code that's downloaded and executed has been reduced. Instead of opting everyone in to a monolithic bundle, only code for the specific features that you're using will be imported at runtime.
  • Workbox has a CDN. We provide a fully supported, Google Cloud Storage-based CDN hosting as the canonical option for accessing the Workbox runtime libraries, making it easier to get up and running with Workbox.
  • 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.