workbox-webpack-plugin
Advanced tools
Comparing version 6.5.0 to 6.5.1
@@ -14,2 +14,31 @@ import webpack from 'webpack'; | ||
* | ||
* @example | ||
* // The following lists some common options; see the rest of the documentation | ||
* // for the full set of options and defaults. | ||
* new GenerateSW({ | ||
* exclude: [/.../, '...'], | ||
* maximumFileSizeToCacheInBytes: ..., | ||
* navigateFallback: '...', | ||
* runtimeCaching: [{ | ||
* // Routing via a matchCallback function: | ||
* urlPattern: ({request, url}) => ..., | ||
* handler: '...', | ||
* options: { | ||
* cacheName: '...', | ||
* expiration: { | ||
* maxEntries: ..., | ||
* }, | ||
* }, | ||
* }, { | ||
* // Routing via a RegExp: | ||
* urlPattern: new RegExp('...'), | ||
* handler: '...', | ||
* options: { | ||
* cacheName: '...', | ||
* plugins: [..., ...], | ||
* }, | ||
* }], | ||
* skipWaiting: ..., | ||
* }); | ||
* | ||
* @memberof module:workbox-webpack-plugin | ||
@@ -22,150 +51,2 @@ */ | ||
* Creates an instance of GenerateSW. | ||
* | ||
* @param {Object} config The configuration to use. | ||
* | ||
* @param {Array<module:workbox-build.ManifestEntry>} [config.additionalManifestEntries] | ||
* A list of entries to be precached, in addition to any entries that are | ||
* generated as part of the build configuration. | ||
* | ||
* @param {Array<string>} [config.babelPresetEnvTargets=['chrome >= 56']] | ||
* The [targets](https://babeljs.io/docs/en/babel-preset-env#targets) to pass to | ||
* `babel-preset-env` when transpiling the service worker bundle. | ||
* | ||
* @param {string} [config.cacheId] An optional ID to be prepended to cache | ||
* names. This is primarily useful for local development where multiple sites | ||
* may be served from the same `http://localhost:port` origin. | ||
* | ||
* @param {boolean} [config.cleanupOutdatedCaches=false] Whether or not Workbox | ||
* should attempt to identify and delete any precaches created by older, | ||
* incompatible versions. | ||
* | ||
* @param {boolean} [config.clientsClaim=false] Whether or not the service | ||
* worker should [start controlling](https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#clientsclaim) | ||
* any existing clients as soon as it activates. | ||
* | ||
* @param {Array<string>} [config.chunks] One or more chunk names whose corresponding | ||
* output files should be included in the precache manifest. | ||
* | ||
* @param {string} [config.directoryIndex='index.html'] If a navigation request | ||
* for a URL ending in `/` fails to match a precached URL, this value will be | ||
* appended to the URL and that will be checked for a precache match. This | ||
* should be set to what your web server is using for its directory index. | ||
* | ||
* @param {RegExp} [config.dontCacheBustURLsMatching] Assets that match this will be | ||
* assumed to be uniquely versioned via their URL, and exempted from the normal | ||
* HTTP cache-busting that's done when populating the precache. (As of Workbox | ||
* v6, this option is usually not needed, as each | ||
* [asset's metadata](https://github.com/webpack/webpack/issues/9038) is used | ||
* to determine whether it's immutable or not.) | ||
* | ||
* @param {Array<string|RegExp>} [config.exclude=[/\.map$/, /^manifest.*\.js$]] | ||
* One or more specifiers used to exclude assets from the precache manifest. | ||
* This is interpreted following | ||
* [the same rules](https://webpack.js.org/configuration/module/#condition) | ||
* as `webpack`'s standard `exclude` option. | ||
* | ||
* @param {Array<string>} [config.excludeChunks] One or more chunk names whose | ||
* corresponding output files should be excluded from the precache manifest. | ||
* | ||
* @param {Array<RegExp>} [config.ignoreURLParametersMatching=[/^utm_/, /^fbclid$/]] | ||
* Any search parameter names that match against one of the RegExp in this array | ||
* will be removed before looking for a precache match. This is useful if your | ||
* users might request URLs that contain, for example, URL parameters used to | ||
* track the source of the traffic. | ||
* | ||
* @param {Array<string>} [config.importScripts] A list of JavaScript files that | ||
* should be passed to [`importScripts()`](https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/importScripts) | ||
* inside the generated service worker file. This is useful when you want to | ||
* let Workbox create your top-level service worker file, but want to include | ||
* some additional code, such as a push event listener. | ||
* | ||
* @param {Array<string>} [config.importScriptsViaChunks] One or more names of | ||
* webpack chunks. The content of those chunks will be included in the | ||
* generated service worker, via a call to `importScripts()`. | ||
* | ||
* @param {Array<string|RegExp>} [config.include] | ||
* One or more specifiers used to include assets in the precache manifest. | ||
* This is interpreted following | ||
* [the same rules](https://webpack.js.org/configuration/module/#condition) | ||
* as `webpack`'s standard `include` option. | ||
* | ||
* @param {boolean} [config.inlineWorkboxRuntime=false] Whether the runtime code | ||
* for the Workbox library should be included in the top-level service worker, | ||
* or split into a separate file that needs to be deployed alongside the service | ||
* worker. Keeping the runtime separate means that users will not have to | ||
* re-download the Workbox code each time your top-level service worker changes. | ||
* | ||
* @param {Array<module:workbox-build.ManifestTransform>} [config.manifestTransforms] | ||
* One or more functions which will be applied sequentially against the | ||
* generated manifest. If `modifyURLPrefix` or `dontCacheBustURLsMatching` are | ||
* also specified, their corresponding transformations will be applied first. | ||
* | ||
* @param {number} [config.maximumFileSizeToCacheInBytes=2097152] This value can be | ||
* used to determine the maximum size of files that will be precached. This | ||
* prevents you from inadvertently precaching very large files that might have | ||
* accidentally matched one of your patterns. | ||
* | ||
* @param {string} [config.mode] If set to 'production', then an optimized service | ||
* worker bundle that excludes debugging info will be produced. If not explicitly | ||
* configured here, the `mode` value configured in the current `webpack` compilation | ||
* will be used. | ||
* | ||
* @param {object<string, string>} [config.modifyURLPrefix] A mapping of prefixes | ||
* that, if present in an entry in the precache manifest, will be replaced with | ||
* the corresponding value. This can be used to, for example, remove or add a | ||
* path prefix from a manifest entry if your web hosting setup doesn't match | ||
* your local filesystem setup. As an alternative with more flexibility, you can | ||
* use the `manifestTransforms` option and provide a function that modifies the | ||
* entries in the manifest using whatever logic you provide. | ||
* | ||
* @param {string} [config.navigateFallback] If specified, all | ||
* [navigation requests](https://developers.google.com/web/fundamentals/primers/service-workers/high-performance-loading#first_what_are_navigation_requests) | ||
* for URLs that aren't precached will be fulfilled with the HTML at the URL | ||
* provided. You must pass in the URL of an HTML document that is listed in your | ||
* precache manifest. This is meant to be used in a Single Page App scenario, in | ||
* which you want all navigations to use common [App Shell HTML](https://developers.google.com/web/fundamentals/architecture/app-shell). | ||
* | ||
* @param {Array<RegExp>} [config.navigateFallbackDenylist] An optional array | ||
* of regular expressions that restricts which URLs the configured | ||
* `navigateFallback` behavior applies to. This is useful if only a subset of | ||
* your site's URLs should be treated as being part of a | ||
* [Single Page App](https://en.wikipedia.org/wiki/Single-page_application). If | ||
* both `navigateFallbackDenylist` and `navigateFallbackAllowlist` are | ||
* configured, the denylist takes precedent. | ||
* | ||
* @param {Array<RegExp>} [config.navigateFallbackAllowlist] An optional array | ||
* of regular expressions that restricts which URLs the configured | ||
* `navigateFallback` behavior applies to. This is useful if only a subset of | ||
* your site's URLs should be treated as being part of a | ||
* [Single Page App](https://en.wikipedia.org/wiki/Single-page_application). If | ||
* both `navigateFallbackDenylist` and `navigateFallbackAllowlist` are | ||
* configured, the denylist takes precedent. | ||
* | ||
* @param {boolean} [config.navigationPreload=false] Whether or not to enable | ||
* [navigation preload](https://developers.google.com/web/tools/workbox/modules/workbox-navigation-preload) | ||
* in the generated service worker. When set to true, you must also use | ||
* `runtimeCaching` to set up an appropriate response strategy that will match | ||
* navigation requests, and make use of the preloaded response. | ||
* | ||
* @param {boolean|Object} [config.offlineGoogleAnalytics=false] Controls | ||
* whether or not to include support for | ||
* [offline Google Analytics](https://developers.google.com/web/tools/workbox/guides/enable-offline-analytics). | ||
* When `true`, the call to `workbox-google-analytics`'s `initialize()` will be | ||
* added to your generated service worker. When set to an `Object`, that object | ||
* will be passed in to the `initialize()` call, allowing you to customize the | ||
* behavior. | ||
* | ||
* @param {Array<module:workbox-build.RuntimeCachingEntry>} [config.runtimeCaching] | ||
* | ||
* @param {boolean} [config.skipWaiting=false] Whether to add an | ||
* unconditional call to [`skipWaiting()`]{@link module:workbox-core.skipWaiting} | ||
* to the generated service worker. If `false`, then a `message` listener will | ||
* be added instead, allowing you to conditionally call `skipWaiting()` by posting | ||
* a message containing {type: 'SKIP_WAITING'}. | ||
* | ||
* @param {boolean} [config.sourcemap=true] Whether to create a sourcemap | ||
* for the generated service worker files. | ||
* | ||
* @param {string} [config.swDest='service-worker.js'] The asset name of the | ||
* service worker file that will be created by this plugin. | ||
*/ | ||
@@ -172,0 +53,0 @@ constructor(config?: GenerateSWConfig); |
@@ -36,156 +36,36 @@ "use strict"; | ||
* | ||
* @example | ||
* // The following lists some common options; see the rest of the documentation | ||
* // for the full set of options and defaults. | ||
* new GenerateSW({ | ||
* exclude: [/.../, '...'], | ||
* maximumFileSizeToCacheInBytes: ..., | ||
* navigateFallback: '...', | ||
* runtimeCaching: [{ | ||
* // Routing via a matchCallback function: | ||
* urlPattern: ({request, url}) => ..., | ||
* handler: '...', | ||
* options: { | ||
* cacheName: '...', | ||
* expiration: { | ||
* maxEntries: ..., | ||
* }, | ||
* }, | ||
* }, { | ||
* // Routing via a RegExp: | ||
* urlPattern: new RegExp('...'), | ||
* handler: '...', | ||
* options: { | ||
* cacheName: '...', | ||
* plugins: [..., ...], | ||
* }, | ||
* }], | ||
* skipWaiting: ..., | ||
* }); | ||
* | ||
* @memberof module:workbox-webpack-plugin | ||
*/ | ||
class GenerateSW { | ||
// eslint-disable-next-line jsdoc/newline-after-description | ||
/** | ||
* Creates an instance of GenerateSW. | ||
* | ||
* @param {Object} config The configuration to use. | ||
* | ||
* @param {Array<module:workbox-build.ManifestEntry>} [config.additionalManifestEntries] | ||
* A list of entries to be precached, in addition to any entries that are | ||
* generated as part of the build configuration. | ||
* | ||
* @param {Array<string>} [config.babelPresetEnvTargets=['chrome >= 56']] | ||
* The [targets](https://babeljs.io/docs/en/babel-preset-env#targets) to pass to | ||
* `babel-preset-env` when transpiling the service worker bundle. | ||
* | ||
* @param {string} [config.cacheId] An optional ID to be prepended to cache | ||
* names. This is primarily useful for local development where multiple sites | ||
* may be served from the same `http://localhost:port` origin. | ||
* | ||
* @param {boolean} [config.cleanupOutdatedCaches=false] Whether or not Workbox | ||
* should attempt to identify and delete any precaches created by older, | ||
* incompatible versions. | ||
* | ||
* @param {boolean} [config.clientsClaim=false] Whether or not the service | ||
* worker should [start controlling](https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#clientsclaim) | ||
* any existing clients as soon as it activates. | ||
* | ||
* @param {Array<string>} [config.chunks] One or more chunk names whose corresponding | ||
* output files should be included in the precache manifest. | ||
* | ||
* @param {string} [config.directoryIndex='index.html'] If a navigation request | ||
* for a URL ending in `/` fails to match a precached URL, this value will be | ||
* appended to the URL and that will be checked for a precache match. This | ||
* should be set to what your web server is using for its directory index. | ||
* | ||
* @param {RegExp} [config.dontCacheBustURLsMatching] Assets that match this will be | ||
* assumed to be uniquely versioned via their URL, and exempted from the normal | ||
* HTTP cache-busting that's done when populating the precache. (As of Workbox | ||
* v6, this option is usually not needed, as each | ||
* [asset's metadata](https://github.com/webpack/webpack/issues/9038) is used | ||
* to determine whether it's immutable or not.) | ||
* | ||
* @param {Array<string|RegExp>} [config.exclude=[/\.map$/, /^manifest.*\.js$]] | ||
* One or more specifiers used to exclude assets from the precache manifest. | ||
* This is interpreted following | ||
* [the same rules](https://webpack.js.org/configuration/module/#condition) | ||
* as `webpack`'s standard `exclude` option. | ||
* | ||
* @param {Array<string>} [config.excludeChunks] One or more chunk names whose | ||
* corresponding output files should be excluded from the precache manifest. | ||
* | ||
* @param {Array<RegExp>} [config.ignoreURLParametersMatching=[/^utm_/, /^fbclid$/]] | ||
* Any search parameter names that match against one of the RegExp in this array | ||
* will be removed before looking for a precache match. This is useful if your | ||
* users might request URLs that contain, for example, URL parameters used to | ||
* track the source of the traffic. | ||
* | ||
* @param {Array<string>} [config.importScripts] A list of JavaScript files that | ||
* should be passed to [`importScripts()`](https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/importScripts) | ||
* inside the generated service worker file. This is useful when you want to | ||
* let Workbox create your top-level service worker file, but want to include | ||
* some additional code, such as a push event listener. | ||
* | ||
* @param {Array<string>} [config.importScriptsViaChunks] One or more names of | ||
* webpack chunks. The content of those chunks will be included in the | ||
* generated service worker, via a call to `importScripts()`. | ||
* | ||
* @param {Array<string|RegExp>} [config.include] | ||
* One or more specifiers used to include assets in the precache manifest. | ||
* This is interpreted following | ||
* [the same rules](https://webpack.js.org/configuration/module/#condition) | ||
* as `webpack`'s standard `include` option. | ||
* | ||
* @param {boolean} [config.inlineWorkboxRuntime=false] Whether the runtime code | ||
* for the Workbox library should be included in the top-level service worker, | ||
* or split into a separate file that needs to be deployed alongside the service | ||
* worker. Keeping the runtime separate means that users will not have to | ||
* re-download the Workbox code each time your top-level service worker changes. | ||
* | ||
* @param {Array<module:workbox-build.ManifestTransform>} [config.manifestTransforms] | ||
* One or more functions which will be applied sequentially against the | ||
* generated manifest. If `modifyURLPrefix` or `dontCacheBustURLsMatching` are | ||
* also specified, their corresponding transformations will be applied first. | ||
* | ||
* @param {number} [config.maximumFileSizeToCacheInBytes=2097152] This value can be | ||
* used to determine the maximum size of files that will be precached. This | ||
* prevents you from inadvertently precaching very large files that might have | ||
* accidentally matched one of your patterns. | ||
* | ||
* @param {string} [config.mode] If set to 'production', then an optimized service | ||
* worker bundle that excludes debugging info will be produced. If not explicitly | ||
* configured here, the `mode` value configured in the current `webpack` compilation | ||
* will be used. | ||
* | ||
* @param {object<string, string>} [config.modifyURLPrefix] A mapping of prefixes | ||
* that, if present in an entry in the precache manifest, will be replaced with | ||
* the corresponding value. This can be used to, for example, remove or add a | ||
* path prefix from a manifest entry if your web hosting setup doesn't match | ||
* your local filesystem setup. As an alternative with more flexibility, you can | ||
* use the `manifestTransforms` option and provide a function that modifies the | ||
* entries in the manifest using whatever logic you provide. | ||
* | ||
* @param {string} [config.navigateFallback] If specified, all | ||
* [navigation requests](https://developers.google.com/web/fundamentals/primers/service-workers/high-performance-loading#first_what_are_navigation_requests) | ||
* for URLs that aren't precached will be fulfilled with the HTML at the URL | ||
* provided. You must pass in the URL of an HTML document that is listed in your | ||
* precache manifest. This is meant to be used in a Single Page App scenario, in | ||
* which you want all navigations to use common [App Shell HTML](https://developers.google.com/web/fundamentals/architecture/app-shell). | ||
* | ||
* @param {Array<RegExp>} [config.navigateFallbackDenylist] An optional array | ||
* of regular expressions that restricts which URLs the configured | ||
* `navigateFallback` behavior applies to. This is useful if only a subset of | ||
* your site's URLs should be treated as being part of a | ||
* [Single Page App](https://en.wikipedia.org/wiki/Single-page_application). If | ||
* both `navigateFallbackDenylist` and `navigateFallbackAllowlist` are | ||
* configured, the denylist takes precedent. | ||
* | ||
* @param {Array<RegExp>} [config.navigateFallbackAllowlist] An optional array | ||
* of regular expressions that restricts which URLs the configured | ||
* `navigateFallback` behavior applies to. This is useful if only a subset of | ||
* your site's URLs should be treated as being part of a | ||
* [Single Page App](https://en.wikipedia.org/wiki/Single-page_application). If | ||
* both `navigateFallbackDenylist` and `navigateFallbackAllowlist` are | ||
* configured, the denylist takes precedent. | ||
* | ||
* @param {boolean} [config.navigationPreload=false] Whether or not to enable | ||
* [navigation preload](https://developers.google.com/web/tools/workbox/modules/workbox-navigation-preload) | ||
* in the generated service worker. When set to true, you must also use | ||
* `runtimeCaching` to set up an appropriate response strategy that will match | ||
* navigation requests, and make use of the preloaded response. | ||
* | ||
* @param {boolean|Object} [config.offlineGoogleAnalytics=false] Controls | ||
* whether or not to include support for | ||
* [offline Google Analytics](https://developers.google.com/web/tools/workbox/guides/enable-offline-analytics). | ||
* When `true`, the call to `workbox-google-analytics`'s `initialize()` will be | ||
* added to your generated service worker. When set to an `Object`, that object | ||
* will be passed in to the `initialize()` call, allowing you to customize the | ||
* behavior. | ||
* | ||
* @param {Array<module:workbox-build.RuntimeCachingEntry>} [config.runtimeCaching] | ||
* | ||
* @param {boolean} [config.skipWaiting=false] Whether to add an | ||
* unconditional call to [`skipWaiting()`]{@link module:workbox-core.skipWaiting} | ||
* to the generated service worker. If `false`, then a `message` listener will | ||
* be added instead, allowing you to conditionally call `skipWaiting()` by posting | ||
* a message containing {type: 'SKIP_WAITING'}. | ||
* | ||
* @param {boolean} [config.sourcemap=true] Whether to create a sourcemap | ||
* for the generated service worker files. | ||
* | ||
* @param {string} [config.swDest='service-worker.js'] The asset name of the | ||
* service worker file that will be created by this plugin. | ||
*/ | ||
@@ -192,0 +72,0 @@ constructor(config = {}) { |
@@ -6,2 +6,7 @@ import { GenerateSW } from './generate-sw'; | ||
*/ | ||
export { GenerateSW, InjectManifest, }; | ||
export { GenerateSW, InjectManifest }; | ||
declare const _default: { | ||
GenerateSW: typeof GenerateSW; | ||
InjectManifest: typeof InjectManifest; | ||
}; | ||
export default _default; |
@@ -15,1 +15,4 @@ "use strict"; | ||
Object.defineProperty(exports, "InjectManifest", { enumerable: true, get: function () { return inject_manifest_1.InjectManifest; } }); | ||
// TODO: remove this in v7. | ||
// See https://github.com/GoogleChrome/workbox/issues/3033 | ||
exports.default = { GenerateSW: generate_sw_1.GenerateSW, InjectManifest: inject_manifest_1.InjectManifest }; |
@@ -12,2 +12,14 @@ import webpack from 'webpack'; | ||
* | ||
* In addition to injecting the manifest, this plugin will perform a compilation | ||
* of the `swSrc` file, using the options from the main webpack configuration. | ||
* | ||
* @example | ||
* // The following lists some common options; see the rest of the documentation | ||
* // for the full set of options and defaults. | ||
* new InjectManifest({ | ||
* exclude: [/.../, '...'], | ||
* maximumFileSizeToCacheInBytes: ..., | ||
* swSrc: '...', | ||
* }); | ||
* | ||
* @memberof module:workbox-webpack-plugin | ||
@@ -20,75 +32,2 @@ */ | ||
* Creates an instance of InjectManifest. | ||
* | ||
* @param {Object} config The configuration to use. | ||
* | ||
* @param {string} config.swSrc An existing service worker file that will be | ||
* compiled and have a precache manifest injected into it. | ||
* | ||
* @param {Array<module:workbox-build.ManifestEntry>} [config.additionalManifestEntries] | ||
* A list of entries to be precached, in addition to any entries that are | ||
* generated as part of the build configuration. | ||
* | ||
* @param {Array<string>} [config.chunks] One or more chunk names whose corresponding | ||
* output files should be included in the precache manifest. | ||
* | ||
* @param {boolean} [config.compileSrc=true] When `true` (the default), the | ||
* `swSrc` file will be compiled by webpack. When `false`, compilation will | ||
* not occur (and `webpackCompilationPlugins` can't be used.) Set to `false` | ||
* if you want to inject the manifest into, e.g., a JSON file. | ||
* | ||
* @param {RegExp} [config.dontCacheBustURLsMatching] Assets that match this will be | ||
* assumed to be uniquely versioned via their URL, and exempted from the normal | ||
* HTTP cache-busting that's done when populating the precache. (As of Workbox | ||
* v6, this option is usually not needed, as each | ||
* [asset's metadata](https://github.com/webpack/webpack/issues/9038) is used | ||
* to determine whether it's immutable or not.) | ||
* | ||
* @param {Array<string|RegExp|Function>} [config.exclude=[/\.map$/, /^manifest.*\.js$]] | ||
* One or more specifiers used to exclude assets from the precache manifest. | ||
* This is interpreted following | ||
* [the same rules](https://webpack.js.org/configuration/module/#condition) | ||
* as `webpack`'s standard `exclude` option. | ||
* | ||
* @param {Array<string>} [config.excludeChunks] One or more chunk names whose | ||
* corresponding output files should be excluded from the precache manifest. | ||
* | ||
* @param {Array<string|RegExp|Function>} [config.include] | ||
* One or more specifiers used to include assets in the precache manifest. | ||
* This is interpreted following | ||
* [the same rules](https://webpack.js.org/configuration/module/#condition) | ||
* as `webpack`'s standard `include` option. | ||
* | ||
* @param {string} [config.injectionPoint='self.__WB_MANIFEST'] The string to | ||
* find inside of the `swSrc` file. Once found, it will be replaced by the | ||
* generated precache manifest. | ||
* | ||
* @param {Array<module:workbox-build.ManifestTransform>} [config.manifestTransforms] | ||
* One or more functions which will be applied sequentially against the | ||
* generated manifest. If `modifyURLPrefix` or `dontCacheBustURLsMatching` are | ||
* also specified, their corresponding transformations will be applied first. | ||
* | ||
* @param {number} [config.maximumFileSizeToCacheInBytes=2097152] This value can be | ||
* used to determine the maximum size of files that will be precached. This | ||
* prevents you from inadvertently precaching very large files that might have | ||
* accidentally matched one of your patterns. | ||
* | ||
* @param {string} [config.mode] If set to 'production', then an optimized service | ||
* worker bundle that excludes debugging info will be produced. If not explicitly | ||
* configured here, the `mode` value configured in the current `webpack` | ||
* compilation will be used. | ||
* | ||
* @param {object<string, string>} [config.modifyURLPrefix] A mapping of prefixes | ||
* that, if present in an entry in the precache manifest, will be replaced with | ||
* the corresponding value. This can be used to, for example, remove or add a | ||
* path prefix from a manifest entry if your web hosting setup doesn't match | ||
* your local filesystem setup. As an alternative with more flexibility, you can | ||
* use the `manifestTransforms` option and provide a function that modifies the | ||
* entries in the manifest using whatever logic you provide. | ||
* | ||
* @param {string} [config.swDest] The asset name of the | ||
* service worker file that will be created by this plugin. If omitted, the | ||
* name will be based on the `swSrc` name. | ||
* | ||
* @param {Array<Object>} [config.webpackCompilationPlugins] Optional `webpack` | ||
* plugins that will be used when compiling the `swSrc` input file. | ||
*/ | ||
@@ -95,0 +34,0 @@ constructor(config: WebpackInjectManifestOptions); |
@@ -41,81 +41,19 @@ "use strict"; | ||
* | ||
* In addition to injecting the manifest, this plugin will perform a compilation | ||
* of the `swSrc` file, using the options from the main webpack configuration. | ||
* | ||
* @example | ||
* // The following lists some common options; see the rest of the documentation | ||
* // for the full set of options and defaults. | ||
* new InjectManifest({ | ||
* exclude: [/.../, '...'], | ||
* maximumFileSizeToCacheInBytes: ..., | ||
* swSrc: '...', | ||
* }); | ||
* | ||
* @memberof module:workbox-webpack-plugin | ||
*/ | ||
class InjectManifest { | ||
// eslint-disable-next-line jsdoc/newline-after-description | ||
/** | ||
* Creates an instance of InjectManifest. | ||
* | ||
* @param {Object} config The configuration to use. | ||
* | ||
* @param {string} config.swSrc An existing service worker file that will be | ||
* compiled and have a precache manifest injected into it. | ||
* | ||
* @param {Array<module:workbox-build.ManifestEntry>} [config.additionalManifestEntries] | ||
* A list of entries to be precached, in addition to any entries that are | ||
* generated as part of the build configuration. | ||
* | ||
* @param {Array<string>} [config.chunks] One or more chunk names whose corresponding | ||
* output files should be included in the precache manifest. | ||
* | ||
* @param {boolean} [config.compileSrc=true] When `true` (the default), the | ||
* `swSrc` file will be compiled by webpack. When `false`, compilation will | ||
* not occur (and `webpackCompilationPlugins` can't be used.) Set to `false` | ||
* if you want to inject the manifest into, e.g., a JSON file. | ||
* | ||
* @param {RegExp} [config.dontCacheBustURLsMatching] Assets that match this will be | ||
* assumed to be uniquely versioned via their URL, and exempted from the normal | ||
* HTTP cache-busting that's done when populating the precache. (As of Workbox | ||
* v6, this option is usually not needed, as each | ||
* [asset's metadata](https://github.com/webpack/webpack/issues/9038) is used | ||
* to determine whether it's immutable or not.) | ||
* | ||
* @param {Array<string|RegExp|Function>} [config.exclude=[/\.map$/, /^manifest.*\.js$]] | ||
* One or more specifiers used to exclude assets from the precache manifest. | ||
* This is interpreted following | ||
* [the same rules](https://webpack.js.org/configuration/module/#condition) | ||
* as `webpack`'s standard `exclude` option. | ||
* | ||
* @param {Array<string>} [config.excludeChunks] One or more chunk names whose | ||
* corresponding output files should be excluded from the precache manifest. | ||
* | ||
* @param {Array<string|RegExp|Function>} [config.include] | ||
* One or more specifiers used to include assets in the precache manifest. | ||
* This is interpreted following | ||
* [the same rules](https://webpack.js.org/configuration/module/#condition) | ||
* as `webpack`'s standard `include` option. | ||
* | ||
* @param {string} [config.injectionPoint='self.__WB_MANIFEST'] The string to | ||
* find inside of the `swSrc` file. Once found, it will be replaced by the | ||
* generated precache manifest. | ||
* | ||
* @param {Array<module:workbox-build.ManifestTransform>} [config.manifestTransforms] | ||
* One or more functions which will be applied sequentially against the | ||
* generated manifest. If `modifyURLPrefix` or `dontCacheBustURLsMatching` are | ||
* also specified, their corresponding transformations will be applied first. | ||
* | ||
* @param {number} [config.maximumFileSizeToCacheInBytes=2097152] This value can be | ||
* used to determine the maximum size of files that will be precached. This | ||
* prevents you from inadvertently precaching very large files that might have | ||
* accidentally matched one of your patterns. | ||
* | ||
* @param {string} [config.mode] If set to 'production', then an optimized service | ||
* worker bundle that excludes debugging info will be produced. If not explicitly | ||
* configured here, the `mode` value configured in the current `webpack` | ||
* compilation will be used. | ||
* | ||
* @param {object<string, string>} [config.modifyURLPrefix] A mapping of prefixes | ||
* that, if present in an entry in the precache manifest, will be replaced with | ||
* the corresponding value. This can be used to, for example, remove or add a | ||
* path prefix from a manifest entry if your web hosting setup doesn't match | ||
* your local filesystem setup. As an alternative with more flexibility, you can | ||
* use the `manifestTransforms` option and provide a function that modifies the | ||
* entries in the manifest using whatever logic you provide. | ||
* | ||
* @param {string} [config.swDest] The asset name of the | ||
* service worker file that will be created by this plugin. If omitted, the | ||
* name will be based on the `swSrc` name. | ||
* | ||
* @param {Array<Object>} [config.webpackCompilationPlugins] Optional `webpack` | ||
* plugins that will be used when compiling the `swSrc` input file. | ||
*/ | ||
@@ -122,0 +60,0 @@ constructor(config) { |
{ | ||
"name": "workbox-webpack-plugin", | ||
"version": "6.5.0", | ||
"version": "6.5.1", | ||
"description": "A plugin for your Webpack build process, helping you generate a manifest of local files that workbox-sw should precache.", | ||
@@ -28,3 +28,3 @@ "keywords": [ | ||
"webpack-sources": "^1.4.3", | ||
"workbox-build": "6.5.0" | ||
"workbox-build": "6.5.1" | ||
}, | ||
@@ -42,3 +42,3 @@ "peerDependencies": { | ||
"homepage": "https://github.com/GoogleChrome/workbox", | ||
"gitHead": "d796009eadcba556b2795e0fea7d71a241f535e0" | ||
"gitHead": "7c095b4f981976d11a29ac934a16c6a0fbd0c0c1" | ||
} |
@@ -39,2 +39,31 @@ /* | ||
* | ||
* @example | ||
* // The following lists some common options; see the rest of the documentation | ||
* // for the full set of options and defaults. | ||
* new GenerateSW({ | ||
* exclude: [/.../, '...'], | ||
* maximumFileSizeToCacheInBytes: ..., | ||
* navigateFallback: '...', | ||
* runtimeCaching: [{ | ||
* // Routing via a matchCallback function: | ||
* urlPattern: ({request, url}) => ..., | ||
* handler: '...', | ||
* options: { | ||
* cacheName: '...', | ||
* expiration: { | ||
* maxEntries: ..., | ||
* }, | ||
* }, | ||
* }, { | ||
* // Routing via a RegExp: | ||
* urlPattern: new RegExp('...'), | ||
* handler: '...', | ||
* options: { | ||
* cacheName: '...', | ||
* plugins: [..., ...], | ||
* }, | ||
* }], | ||
* skipWaiting: ..., | ||
* }); | ||
* | ||
* @memberof module:workbox-webpack-plugin | ||
@@ -45,153 +74,5 @@ */ | ||
private alreadyCalled: boolean; | ||
// eslint-disable-next-line jsdoc/newline-after-description | ||
/** | ||
* Creates an instance of GenerateSW. | ||
* | ||
* @param {Object} config The configuration to use. | ||
* | ||
* @param {Array<module:workbox-build.ManifestEntry>} [config.additionalManifestEntries] | ||
* A list of entries to be precached, in addition to any entries that are | ||
* generated as part of the build configuration. | ||
* | ||
* @param {Array<string>} [config.babelPresetEnvTargets=['chrome >= 56']] | ||
* The [targets](https://babeljs.io/docs/en/babel-preset-env#targets) to pass to | ||
* `babel-preset-env` when transpiling the service worker bundle. | ||
* | ||
* @param {string} [config.cacheId] An optional ID to be prepended to cache | ||
* names. This is primarily useful for local development where multiple sites | ||
* may be served from the same `http://localhost:port` origin. | ||
* | ||
* @param {boolean} [config.cleanupOutdatedCaches=false] Whether or not Workbox | ||
* should attempt to identify and delete any precaches created by older, | ||
* incompatible versions. | ||
* | ||
* @param {boolean} [config.clientsClaim=false] Whether or not the service | ||
* worker should [start controlling](https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#clientsclaim) | ||
* any existing clients as soon as it activates. | ||
* | ||
* @param {Array<string>} [config.chunks] One or more chunk names whose corresponding | ||
* output files should be included in the precache manifest. | ||
* | ||
* @param {string} [config.directoryIndex='index.html'] If a navigation request | ||
* for a URL ending in `/` fails to match a precached URL, this value will be | ||
* appended to the URL and that will be checked for a precache match. This | ||
* should be set to what your web server is using for its directory index. | ||
* | ||
* @param {RegExp} [config.dontCacheBustURLsMatching] Assets that match this will be | ||
* assumed to be uniquely versioned via their URL, and exempted from the normal | ||
* HTTP cache-busting that's done when populating the precache. (As of Workbox | ||
* v6, this option is usually not needed, as each | ||
* [asset's metadata](https://github.com/webpack/webpack/issues/9038) is used | ||
* to determine whether it's immutable or not.) | ||
* | ||
* @param {Array<string|RegExp>} [config.exclude=[/\.map$/, /^manifest.*\.js$]] | ||
* One or more specifiers used to exclude assets from the precache manifest. | ||
* This is interpreted following | ||
* [the same rules](https://webpack.js.org/configuration/module/#condition) | ||
* as `webpack`'s standard `exclude` option. | ||
* | ||
* @param {Array<string>} [config.excludeChunks] One or more chunk names whose | ||
* corresponding output files should be excluded from the precache manifest. | ||
* | ||
* @param {Array<RegExp>} [config.ignoreURLParametersMatching=[/^utm_/, /^fbclid$/]] | ||
* Any search parameter names that match against one of the RegExp in this array | ||
* will be removed before looking for a precache match. This is useful if your | ||
* users might request URLs that contain, for example, URL parameters used to | ||
* track the source of the traffic. | ||
* | ||
* @param {Array<string>} [config.importScripts] A list of JavaScript files that | ||
* should be passed to [`importScripts()`](https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/importScripts) | ||
* inside the generated service worker file. This is useful when you want to | ||
* let Workbox create your top-level service worker file, but want to include | ||
* some additional code, such as a push event listener. | ||
* | ||
* @param {Array<string>} [config.importScriptsViaChunks] One or more names of | ||
* webpack chunks. The content of those chunks will be included in the | ||
* generated service worker, via a call to `importScripts()`. | ||
* | ||
* @param {Array<string|RegExp>} [config.include] | ||
* One or more specifiers used to include assets in the precache manifest. | ||
* This is interpreted following | ||
* [the same rules](https://webpack.js.org/configuration/module/#condition) | ||
* as `webpack`'s standard `include` option. | ||
* | ||
* @param {boolean} [config.inlineWorkboxRuntime=false] Whether the runtime code | ||
* for the Workbox library should be included in the top-level service worker, | ||
* or split into a separate file that needs to be deployed alongside the service | ||
* worker. Keeping the runtime separate means that users will not have to | ||
* re-download the Workbox code each time your top-level service worker changes. | ||
* | ||
* @param {Array<module:workbox-build.ManifestTransform>} [config.manifestTransforms] | ||
* One or more functions which will be applied sequentially against the | ||
* generated manifest. If `modifyURLPrefix` or `dontCacheBustURLsMatching` are | ||
* also specified, their corresponding transformations will be applied first. | ||
* | ||
* @param {number} [config.maximumFileSizeToCacheInBytes=2097152] This value can be | ||
* used to determine the maximum size of files that will be precached. This | ||
* prevents you from inadvertently precaching very large files that might have | ||
* accidentally matched one of your patterns. | ||
* | ||
* @param {string} [config.mode] If set to 'production', then an optimized service | ||
* worker bundle that excludes debugging info will be produced. If not explicitly | ||
* configured here, the `mode` value configured in the current `webpack` compilation | ||
* will be used. | ||
* | ||
* @param {object<string, string>} [config.modifyURLPrefix] A mapping of prefixes | ||
* that, if present in an entry in the precache manifest, will be replaced with | ||
* the corresponding value. This can be used to, for example, remove or add a | ||
* path prefix from a manifest entry if your web hosting setup doesn't match | ||
* your local filesystem setup. As an alternative with more flexibility, you can | ||
* use the `manifestTransforms` option and provide a function that modifies the | ||
* entries in the manifest using whatever logic you provide. | ||
* | ||
* @param {string} [config.navigateFallback] If specified, all | ||
* [navigation requests](https://developers.google.com/web/fundamentals/primers/service-workers/high-performance-loading#first_what_are_navigation_requests) | ||
* for URLs that aren't precached will be fulfilled with the HTML at the URL | ||
* provided. You must pass in the URL of an HTML document that is listed in your | ||
* precache manifest. This is meant to be used in a Single Page App scenario, in | ||
* which you want all navigations to use common [App Shell HTML](https://developers.google.com/web/fundamentals/architecture/app-shell). | ||
* | ||
* @param {Array<RegExp>} [config.navigateFallbackDenylist] An optional array | ||
* of regular expressions that restricts which URLs the configured | ||
* `navigateFallback` behavior applies to. This is useful if only a subset of | ||
* your site's URLs should be treated as being part of a | ||
* [Single Page App](https://en.wikipedia.org/wiki/Single-page_application). If | ||
* both `navigateFallbackDenylist` and `navigateFallbackAllowlist` are | ||
* configured, the denylist takes precedent. | ||
* | ||
* @param {Array<RegExp>} [config.navigateFallbackAllowlist] An optional array | ||
* of regular expressions that restricts which URLs the configured | ||
* `navigateFallback` behavior applies to. This is useful if only a subset of | ||
* your site's URLs should be treated as being part of a | ||
* [Single Page App](https://en.wikipedia.org/wiki/Single-page_application). If | ||
* both `navigateFallbackDenylist` and `navigateFallbackAllowlist` are | ||
* configured, the denylist takes precedent. | ||
* | ||
* @param {boolean} [config.navigationPreload=false] Whether or not to enable | ||
* [navigation preload](https://developers.google.com/web/tools/workbox/modules/workbox-navigation-preload) | ||
* in the generated service worker. When set to true, you must also use | ||
* `runtimeCaching` to set up an appropriate response strategy that will match | ||
* navigation requests, and make use of the preloaded response. | ||
* | ||
* @param {boolean|Object} [config.offlineGoogleAnalytics=false] Controls | ||
* whether or not to include support for | ||
* [offline Google Analytics](https://developers.google.com/web/tools/workbox/guides/enable-offline-analytics). | ||
* When `true`, the call to `workbox-google-analytics`'s `initialize()` will be | ||
* added to your generated service worker. When set to an `Object`, that object | ||
* will be passed in to the `initialize()` call, allowing you to customize the | ||
* behavior. | ||
* | ||
* @param {Array<module:workbox-build.RuntimeCachingEntry>} [config.runtimeCaching] | ||
* | ||
* @param {boolean} [config.skipWaiting=false] Whether to add an | ||
* unconditional call to [`skipWaiting()`]{@link module:workbox-core.skipWaiting} | ||
* to the generated service worker. If `false`, then a `message` listener will | ||
* be added instead, allowing you to conditionally call `skipWaiting()` by posting | ||
* a message containing {type: 'SKIP_WAITING'}. | ||
* | ||
* @param {boolean} [config.sourcemap=true] Whether to create a sourcemap | ||
* for the generated service worker files. | ||
* | ||
* @param {string} [config.swDest='service-worker.js'] The asset name of the | ||
* service worker file that will be created by this plugin. | ||
*/ | ||
@@ -198,0 +79,0 @@ constructor(config: GenerateSWConfig = {}) { |
@@ -15,6 +15,6 @@ /* | ||
*/ | ||
export {GenerateSW, InjectManifest}; | ||
export { | ||
GenerateSW, | ||
InjectManifest, | ||
}; | ||
// TODO: remove this in v7. | ||
// See https://github.com/GoogleChrome/workbox/issues/3033 | ||
export default {GenerateSW, InjectManifest}; |
@@ -41,2 +41,14 @@ /* | ||
* | ||
* In addition to injecting the manifest, this plugin will perform a compilation | ||
* of the `swSrc` file, using the options from the main webpack configuration. | ||
* | ||
* @example | ||
* // The following lists some common options; see the rest of the documentation | ||
* // for the full set of options and defaults. | ||
* new InjectManifest({ | ||
* exclude: [/.../, '...'], | ||
* maximumFileSizeToCacheInBytes: ..., | ||
* swSrc: '...', | ||
* }); | ||
* | ||
* @memberof module:workbox-webpack-plugin | ||
@@ -47,78 +59,5 @@ */ | ||
private alreadyCalled: boolean; | ||
// eslint-disable-next-line jsdoc/newline-after-description | ||
/** | ||
* Creates an instance of InjectManifest. | ||
* | ||
* @param {Object} config The configuration to use. | ||
* | ||
* @param {string} config.swSrc An existing service worker file that will be | ||
* compiled and have a precache manifest injected into it. | ||
* | ||
* @param {Array<module:workbox-build.ManifestEntry>} [config.additionalManifestEntries] | ||
* A list of entries to be precached, in addition to any entries that are | ||
* generated as part of the build configuration. | ||
* | ||
* @param {Array<string>} [config.chunks] One or more chunk names whose corresponding | ||
* output files should be included in the precache manifest. | ||
* | ||
* @param {boolean} [config.compileSrc=true] When `true` (the default), the | ||
* `swSrc` file will be compiled by webpack. When `false`, compilation will | ||
* not occur (and `webpackCompilationPlugins` can't be used.) Set to `false` | ||
* if you want to inject the manifest into, e.g., a JSON file. | ||
* | ||
* @param {RegExp} [config.dontCacheBustURLsMatching] Assets that match this will be | ||
* assumed to be uniquely versioned via their URL, and exempted from the normal | ||
* HTTP cache-busting that's done when populating the precache. (As of Workbox | ||
* v6, this option is usually not needed, as each | ||
* [asset's metadata](https://github.com/webpack/webpack/issues/9038) is used | ||
* to determine whether it's immutable or not.) | ||
* | ||
* @param {Array<string|RegExp|Function>} [config.exclude=[/\.map$/, /^manifest.*\.js$]] | ||
* One or more specifiers used to exclude assets from the precache manifest. | ||
* This is interpreted following | ||
* [the same rules](https://webpack.js.org/configuration/module/#condition) | ||
* as `webpack`'s standard `exclude` option. | ||
* | ||
* @param {Array<string>} [config.excludeChunks] One or more chunk names whose | ||
* corresponding output files should be excluded from the precache manifest. | ||
* | ||
* @param {Array<string|RegExp|Function>} [config.include] | ||
* One or more specifiers used to include assets in the precache manifest. | ||
* This is interpreted following | ||
* [the same rules](https://webpack.js.org/configuration/module/#condition) | ||
* as `webpack`'s standard `include` option. | ||
* | ||
* @param {string} [config.injectionPoint='self.__WB_MANIFEST'] The string to | ||
* find inside of the `swSrc` file. Once found, it will be replaced by the | ||
* generated precache manifest. | ||
* | ||
* @param {Array<module:workbox-build.ManifestTransform>} [config.manifestTransforms] | ||
* One or more functions which will be applied sequentially against the | ||
* generated manifest. If `modifyURLPrefix` or `dontCacheBustURLsMatching` are | ||
* also specified, their corresponding transformations will be applied first. | ||
* | ||
* @param {number} [config.maximumFileSizeToCacheInBytes=2097152] This value can be | ||
* used to determine the maximum size of files that will be precached. This | ||
* prevents you from inadvertently precaching very large files that might have | ||
* accidentally matched one of your patterns. | ||
* | ||
* @param {string} [config.mode] If set to 'production', then an optimized service | ||
* worker bundle that excludes debugging info will be produced. If not explicitly | ||
* configured here, the `mode` value configured in the current `webpack` | ||
* compilation will be used. | ||
* | ||
* @param {object<string, string>} [config.modifyURLPrefix] A mapping of prefixes | ||
* that, if present in an entry in the precache manifest, will be replaced with | ||
* the corresponding value. This can be used to, for example, remove or add a | ||
* path prefix from a manifest entry if your web hosting setup doesn't match | ||
* your local filesystem setup. As an alternative with more flexibility, you can | ||
* use the `manifestTransforms` option and provide a function that modifies the | ||
* entries in the manifest using whatever logic you provide. | ||
* | ||
* @param {string} [config.swDest] The asset name of the | ||
* service worker file that will be created by this plugin. If omitted, the | ||
* name will be based on the `swSrc` name. | ||
* | ||
* @param {Array<Object>} [config.webpackCompilationPlugins] Optional `webpack` | ||
* plugins that will be used when compiling the `swSrc` input file. | ||
*/ | ||
@@ -125,0 +64,0 @@ constructor(config: WebpackInjectManifestOptions) { |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
118515
2036
+ Addedcaniuse-lite@1.0.30001620(transitive)
+ Addedelectron-to-chromium@1.4.773(transitive)
+ Addedworkbox-background-sync@6.5.1(transitive)
+ Addedworkbox-broadcast-update@6.5.1(transitive)
+ Addedworkbox-build@6.5.1(transitive)
+ Addedworkbox-cacheable-response@6.5.1(transitive)
+ Addedworkbox-core@6.5.1(transitive)
+ Addedworkbox-expiration@6.5.1(transitive)
+ Addedworkbox-google-analytics@6.5.1(transitive)
+ Addedworkbox-navigation-preload@6.5.1(transitive)
+ Addedworkbox-precaching@6.5.1(transitive)
+ Addedworkbox-range-requests@6.5.1(transitive)
+ Addedworkbox-recipes@6.5.1(transitive)
+ Addedworkbox-routing@6.5.1(transitive)
+ Addedworkbox-strategies@6.5.1(transitive)
+ Addedworkbox-streams@6.5.1(transitive)
+ Addedworkbox-sw@6.5.1(transitive)
+ Addedworkbox-window@6.5.1(transitive)
- Removedcaniuse-lite@1.0.30001618(transitive)
- Removedelectron-to-chromium@1.4.769(transitive)
- Removedworkbox-background-sync@6.5.0(transitive)
- Removedworkbox-broadcast-update@6.5.0(transitive)
- Removedworkbox-build@6.5.0(transitive)
- Removedworkbox-cacheable-response@6.5.0(transitive)
- Removedworkbox-core@6.5.0(transitive)
- Removedworkbox-expiration@6.5.0(transitive)
- Removedworkbox-google-analytics@6.5.0(transitive)
- Removedworkbox-navigation-preload@6.5.0(transitive)
- Removedworkbox-precaching@6.5.0(transitive)
- Removedworkbox-range-requests@6.5.0(transitive)
- Removedworkbox-recipes@6.5.0(transitive)
- Removedworkbox-routing@6.5.0(transitive)
- Removedworkbox-strategies@6.5.0(transitive)
- Removedworkbox-streams@6.5.0(transitive)
- Removedworkbox-sw@6.5.0(transitive)
- Removedworkbox-window@6.5.0(transitive)
Updatedworkbox-build@6.5.1