generateSW uses custom Workbox runtime bundles, not CDN #2064
Labels
Breaking Change
Denotes a "major" semver change.
Discuss
An open question, where input from the community would be appreciated.
workbox-build
workbox-cli
workbox-webpack-plugin
Milestone
My current plan for Workbox v5's
generateSW
mode is to produce output that uses a custom bundle of the Workbox runtime, which includes code for only the features of Workbox that are used by the configuration you provide.This will effectively automate the process described in "Using Bundlers (webpack/Rollup) with Workbox" for folks who want the simplicity of
generateSW
mode. (It will use Rollup under the hood for the actual bundling and code elimination.)Because the underlying template used in
generateSW
mode looks very different when the Workbox runtime is referenced via a custom bundle vs. when the Workbox runtime is loaded from the CDN viaworkbox-sw
, I plan on removing the ability to use the CDN copy of Workbox withgenerateSW
mode, along with theimportWorkboxFrom
configuration option.For the time being, we will still publish bundles of the Workbox runtime to the CDN, but my expectation is that it will be only be useful for
injectManifest
users. Longer-term, we may phase out the CDN entirely, and encourage all developers to go through a flow that produces a Workbox runtime bundle that's customized for their specific usage.Parameter changes
As mentioned above,
importWorkboxFrom
will no longer be supported ingenerateSW
mode.New configuration parameters that I anticipate adding include:
inlineWorkboxRuntime
, defaulting tofalse
, which controls whether the Workbox runtime code is inlined into a single service worker file, or whether the runtime code for the Workbox libraries are output into a separate, versioned file that is automatically pulled in to the main service worker viaimportScripts()
.mode
, defaulting to eitherprocess.env.NODE_ENV || 'production'
, which controls whetherterser
is used, and whether Workbox's option code for, e.g., enhanced logging is enabled or disabled in the generated bundle.sourcemap
, defaulting totrue
, which controls whether sourcemaps are also created for the generated file(s).babelPresetEnvTargets
, defaulting to['chrome >= 56']
, which controls what transpilation is performed via@babel/preset-env
when creating the generated file(s).['chrome >= 56']
matches the setting currently used when we produce our CDN-hosted bundles.The text was updated successfully, but these errors were encountered: