Socket
Socket
Sign inDemoInstall

workbox-build

Package Overview
Dependencies
Maintainers
4
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

workbox-build - npm Package Compare versions

Comparing version 5.0.0-alpha.2 to 5.0.0-beta.0

build/generate-sw.js

2

build/cdn-details.json

@@ -5,3 +5,3 @@ {

"releasesDir": "releases",
"latestVersion": "5.0.0-alpha.2"
"latestVersion": "5.0.0-beta.0"
}

@@ -10,65 +10,14 @@ "use strict";

*/
const {
getModuleURL
} = require('./lib/cdn-utils');
const copyWorkboxLibraries = require('./lib/copy-workbox-libraries');
const generateSW = require('./entry-points/generate-sw');
const generateSW = require('./generate-sw');
const getManifest = require('./entry-points/get-manifest');
const getManifest = require('./get-manifest');
const injectManifest = require('./entry-points/inject-manifest');
const {
getModuleURL
} = require('./lib/cdn-utils');
const injectManifest = require('./inject-manifest');
/**
* This Node module can be used to generate a list of assets that should be
* precached in a service worker, generating a hash that can be used to
* intelligently update a cache when the service worker is updated.
*
* This module will use glob patterns to find assets in a given directory
* and use the resulting URL and revision data for one of the follow uses:
*
* 1. Generate a complete service worker with precaching and some basic
* configurable options, writing the resulting service worker file to disk. See
* [generateSW()]{@link module:workbox-build.generateSW}.
* 1. Inject a manifest into an existing service worker. This allows you
* to control your own service worker while still taking advantage of
* [workboxSW.precache()]{@link module:workbox-sw.WorkboxSW#precache} logic.
* See [injectManifest()]{@link module:workbox-build.injectManifest}.
* 1. Just generate a manifest, not a full service worker file.
* This is useful if you want to make use of the manifest from your own existing
* service worker file and are okay with including the manifest yourself.
* See [getManifest()]{@link module:workbox-build.getManifest}.
*
* @property {Array<RegExp>} [ignoreURLParametersMatching=[/^utm_/]] Any
* search parameter names that match against one of the regex's 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. Those URL parameters
* would normally cause the cache lookup to fail, since the URL strings used
* as cache keys would not be expected to include them.
*
* You can use `[/./]` to ignore all URL parameters.
*
* Note: This option is only valid when used with
* {@link module:workbox-build#generateSW|generateSW()}. When using
* {@link module:workbox-build.injectManifest|injectManifest()}, you can
* explicitly pass the desired value in to the
* {@link module:workbox-sw.WorkboxSW|WorkboxSW() constructor} in your `swSrc`
* file.
*
* E.g. `[/homescreen/]`
*
* @property {Boolean} [handleFetch=true] Whether or not `workbox-sw` should
* create a `fetch` event handler that responds to network requests. This is
* useful during development if you don't want the service worker serving stale
* content.
*
* Note: This option is only valid when used with
* {@link module:workbox-build#generateSW|generateSW()}. When using
* {@link module:workbox-build.injectManifest|injectManifest()}, you can
* explicitly pass the desired value in to the
* {@link module:workbox-sw.WorkboxSW|WorkboxSW() constructor} in your `swSrc`
* file.
*
* @module workbox-build

@@ -75,0 +24,0 @@ */

@@ -112,3 +112,7 @@ "use strict";

object with a 'url' property, and a 'revision' property set to null
(e.g. {url: 'https://example.com/v1.0/index.js', revision: null}).`
(e.g. {url: 'https://example.com/v1.0/index.js', revision: null}).`,
'no-manifest-entries-or-runtime-caching': ol`Couldn't find configuration for
either precaching or runtime caching. Please ensure that the various glob
options are set to match one or more files, and/or configure the
runtimeCaching option.`
};

@@ -121,3 +121,3 @@ "use strict";

const transformedManifest = transformManifest({
const transformedManifest = await transformManifest({
additionalManifestEntries,

@@ -124,0 +124,0 @@ dontCacheBustURLsMatching,

@@ -29,3 +29,3 @@ "use strict";

importScripts,
manifestEntries,
manifestEntries = [],
navigateFallback,

@@ -36,6 +36,11 @@ navigateFallbackBlacklist,

offlineGoogleAnalytics,
runtimeCaching,
runtimeCaching = [],
skipWaiting
}) => {
// These are all options that can be passed to the precacheAndRoute() method.
// There needs to be at least something to precache, or else runtime caching.
if (!(manifestEntries.length > 0 || runtimeCaching.length > 0)) {
throw new Error(errors['no-manifest-entries-or-runtime-caching']);
} // These are all options that can be passed to the precacheAndRoute() method.
const precacheOptions = {

@@ -42,0 +47,0 @@ directoryIndex,

@@ -36,3 +36,3 @@ "use strict";

} // Pull handler-specific config from the options object, since they are
// not directly used to construct a Plugin instance. If set, need to be
// not directly used to construct a plugin instance. If set, need to be
// passed as options to the handler constructor instead.

@@ -52,3 +52,3 @@

for (const [pluginName, pluginConfig] of Object.entries(options)) {
// Ensure that we have some valid configuration to pass to Plugin().
// Ensure that we have some valid configuration to pass to the plugin.
if (Object.keys(pluginConfig).length === 0) {

@@ -64,3 +64,3 @@ continue;

const name = pluginConfig.name;
const plugin = moduleRegistry.use('workbox-background-sync', 'Plugin');
const plugin = moduleRegistry.use('workbox-background-sync', 'BackgroundSyncPlugin');
pluginCode = `new ${plugin}(${JSON.stringify(name)}`;

@@ -82,3 +82,3 @@

}, pluginConfig.options);
const plugin = moduleRegistry.use('workbox-broadcast-update', 'Plugin');
const plugin = moduleRegistry.use('workbox-broadcast-update', 'BroadcastUpdatePlugin');
pluginCode = `new ${plugin}(${stringifyWithoutComments(opts)})`;

@@ -90,3 +90,3 @@ break;

{
const plugin = moduleRegistry.use('workbox-cacheable-response', 'Plugin');
const plugin = moduleRegistry.use('workbox-cacheable-response', 'CacheableResponsePlugin');
pluginCode = `new ${plugin}(${stringifyWithoutComments(pluginConfig)})`;

@@ -98,3 +98,3 @@ break;

{
const plugin = moduleRegistry.use('workbox-expiration', 'Plugin');
const plugin = moduleRegistry.use('workbox-expiration', 'ExpirationPlugin');
pluginCode = `new ${plugin}(${stringifyWithoutComments(pluginConfig)})`;

@@ -124,3 +124,3 @@ break;

module.exports = (moduleRegistry, runtimeCaching = []) => {
module.exports = (moduleRegistry, runtimeCaching) => {
return runtimeCaching.map(entry => {

@@ -127,0 +127,0 @@ const method = entry.method || 'GET';

@@ -33,3 +33,3 @@ "use strict";

*
* const cdnTransform = (manifestEntries) => {
* const cdnTransform = async (manifestEntries) => {
* const manifest = manifestEntries.map(entry => {

@@ -49,3 +49,3 @@ * const cdnOrigin = 'https://example.com';

*
* const removeRevisionTransform = (manifestEntries) => {
* const removeRevisionTransform = async (manifestEntries) => {
* const manifest = manifestEntries.map(entry => {

@@ -66,3 +66,3 @@ * const hashRegExp = /\.\w{8}\./;

* will be set to the current `compilation`.
* @return {module:workbox-build.ManifestTransformResult}
* @return {Promise<module:workbox-build.ManifestTransformResult>}
* The array of entries with the transformation applied, and optionally, any

@@ -75,3 +75,3 @@ * warnings that should be reported back to the build tool.

module.exports = ({
module.exports = async ({
additionalManifestEntries,

@@ -122,3 +122,3 @@ dontCacheBustURLsMatching,

for (const transform of transformsToApply) {
const result = transform(transformedManifest, transformParam);
const result = await transform(transformedManifest, transformParam);

@@ -125,0 +125,0 @@ if (!('manifest' in result)) {

@@ -43,15 +43,9 @@ "use strict";

<% if (Array.isArray(manifestEntries)) {%>
<% if (Array.isArray(manifestEntries) && manifestEntries.length > 0) {%>
/**
* The workboxSW.precacheAndRoute() method efficiently caches and responds to
* The precacheAndRoute() method efficiently caches and responds to
* requests for URLs in the manifest.
* See https://goo.gl/S9QRab
*/
self.__precacheManifest = <%= JSON.stringify(manifestEntries, null, 2) %>.concat(self.__precacheManifest || []);
<%= use('workbox-precaching', 'precacheAndRoute') %>(self.__precacheManifest, <%= precacheOptionsString %>);
<% } else { %>
if (Array.isArray(self.__precacheManifest)) {
<%= use('workbox-precaching', 'precacheAndRoute') %>(self.__precacheManifest, <%= precacheOptionsString %>);
}
<% } %>
<%= use('workbox-precaching', 'precacheAndRoute') %>(<%= JSON.stringify(manifestEntries, null, 2) %>, <%= precacheOptionsString %>);
<% if (cleanupOutdatedCaches) { %><%= use('workbox-precaching', 'cleanupOutdatedCaches') %>();<% } %>

@@ -62,2 +56,3 @@ <% if (navigateFallback) { %><%= use('workbox-routing', 'registerRoute') %>(new <%= use('workbox-routing', 'NavigationRoute') %>(<%= use('workbox-precaching', 'createHandlerForURL') %>(<%= JSON.stringify(navigateFallback) %>)<% if (navigateFallbackWhitelist || navigateFallbackBlacklist) { %>, {

}<% } %>));<% } %>
<% } %>

@@ -64,0 +59,0 @@ <% if (runtimeCaching) { runtimeCaching.forEach(runtimeCachingString => {%><%= runtimeCachingString %><% });} %>

{
"name": "workbox-build",
"version": "5.0.0-alpha.2",
"version": "5.0.0-beta.0",
"description": "A module that integrates into your build process, helping you generate a manifest of local files that workbox-sw should precache.",

@@ -42,16 +42,16 @@ "keywords": [

"upath": "^1.1.2",
"workbox-background-sync": "^5.0.0-alpha.2",
"workbox-broadcast-update": "^5.0.0-alpha.2",
"workbox-cacheable-response": "^5.0.0-alpha.2",
"workbox-core": "^5.0.0-alpha.2",
"workbox-expiration": "^5.0.0-alpha.2",
"workbox-google-analytics": "^5.0.0-alpha.2",
"workbox-navigation-preload": "^5.0.0-alpha.2",
"workbox-precaching": "^5.0.0-alpha.2",
"workbox-range-requests": "^5.0.0-alpha.2",
"workbox-routing": "^5.0.0-alpha.2",
"workbox-strategies": "^5.0.0-alpha.2",
"workbox-streams": "^5.0.0-alpha.2",
"workbox-sw": "^5.0.0-alpha.2",
"workbox-window": "^5.0.0-alpha.2"
"workbox-background-sync": "^5.0.0-beta.0",
"workbox-broadcast-update": "^5.0.0-beta.0",
"workbox-cacheable-response": "^5.0.0-beta.0",
"workbox-core": "^5.0.0-beta.0",
"workbox-expiration": "^5.0.0-beta.0",
"workbox-google-analytics": "^5.0.0-beta.0",
"workbox-navigation-preload": "^5.0.0-beta.0",
"workbox-precaching": "^5.0.0-beta.0",
"workbox-range-requests": "^5.0.0-beta.0",
"workbox-routing": "^5.0.0-beta.0",
"workbox-strategies": "^5.0.0-beta.0",
"workbox-streams": "^5.0.0-beta.0",
"workbox-sw": "^5.0.0-beta.0",
"workbox-window": "^5.0.0-beta.0"
},

@@ -67,3 +67,3 @@ "main": "build/index.js",

},
"gitHead": "0cb0029b692c3802545238fe59b6d6179ca32f6c"
"gitHead": "136b38f2c701bd7c04e808d19961310a9ede524b"
}

@@ -5,3 +5,3 @@ {

"releasesDir": "releases",
"latestVersion": "5.0.0-alpha.2"
"latestVersion": "5.0.0-beta.0"
}

@@ -9,60 +9,9 @@ /*

const {getModuleURL} = require('./lib/cdn-utils');
const copyWorkboxLibraries = require('./lib/copy-workbox-libraries');
const generateSW = require('./entry-points/generate-sw');
const getManifest = require('./entry-points/get-manifest');
const injectManifest = require('./entry-points/inject-manifest');
const {getModuleURL} = require('./lib/cdn-utils');
const generateSW = require('./generate-sw');
const getManifest = require('./get-manifest');
const injectManifest = require('./inject-manifest');
/**
* This Node module can be used to generate a list of assets that should be
* precached in a service worker, generating a hash that can be used to
* intelligently update a cache when the service worker is updated.
*
* This module will use glob patterns to find assets in a given directory
* and use the resulting URL and revision data for one of the follow uses:
*
* 1. Generate a complete service worker with precaching and some basic
* configurable options, writing the resulting service worker file to disk. See
* [generateSW()]{@link module:workbox-build.generateSW}.
* 1. Inject a manifest into an existing service worker. This allows you
* to control your own service worker while still taking advantage of
* [workboxSW.precache()]{@link module:workbox-sw.WorkboxSW#precache} logic.
* See [injectManifest()]{@link module:workbox-build.injectManifest}.
* 1. Just generate a manifest, not a full service worker file.
* This is useful if you want to make use of the manifest from your own existing
* service worker file and are okay with including the manifest yourself.
* See [getManifest()]{@link module:workbox-build.getManifest}.
*
* @property {Array<RegExp>} [ignoreURLParametersMatching=[/^utm_/]] Any
* search parameter names that match against one of the regex's 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. Those URL parameters
* would normally cause the cache lookup to fail, since the URL strings used
* as cache keys would not be expected to include them.
*
* You can use `[/./]` to ignore all URL parameters.
*
* Note: This option is only valid when used with
* {@link module:workbox-build#generateSW|generateSW()}. When using
* {@link module:workbox-build.injectManifest|injectManifest()}, you can
* explicitly pass the desired value in to the
* {@link module:workbox-sw.WorkboxSW|WorkboxSW() constructor} in your `swSrc`
* file.
*
* E.g. `[/homescreen/]`
*
* @property {Boolean} [handleFetch=true] Whether or not `workbox-sw` should
* create a `fetch` event handler that responds to network requests. This is
* useful during development if you don't want the service worker serving stale
* content.
*
* Note: This option is only valid when used with
* {@link module:workbox-build#generateSW|generateSW()}. When using
* {@link module:workbox-build.injectManifest|injectManifest()}, you can
* explicitly pass the desired value in to the
* {@link module:workbox-sw.WorkboxSW|WorkboxSW() constructor} in your `swSrc`
* file.
*
* @module workbox-build

@@ -69,0 +18,0 @@ */

@@ -113,2 +113,6 @@ /*

(e.g. {url: 'https://example.com/v1.0/index.js', revision: null}).`,
'no-manifest-entries-or-runtime-caching': ol`Couldn't find configuration for
either precaching or runtime caching. Please ensure that the various glob
options are set to match one or more files, and/or configure the
runtimeCaching option.`,
};

@@ -111,3 +111,3 @@ /*

const transformedManifest = transformManifest({
const transformedManifest = await transformManifest({
additionalManifestEntries,

@@ -114,0 +114,0 @@ dontCacheBustURLsMatching,

@@ -24,3 +24,3 @@ /*

importScripts,
manifestEntries,
manifestEntries = [],
navigateFallback,

@@ -31,5 +31,10 @@ navigateFallbackBlacklist,

offlineGoogleAnalytics,
runtimeCaching,
runtimeCaching = [],
skipWaiting,
}) => {
// There needs to be at least something to precache, or else runtime caching.
if (!(manifestEntries.length > 0 || runtimeCaching.length > 0)) {
throw new Error(errors['no-manifest-entries-or-runtime-caching']);
}
// These are all options that can be passed to the precacheAndRoute() method.

@@ -36,0 +41,0 @@ const precacheOptions = {

@@ -34,3 +34,3 @@ /*

// Pull handler-specific config from the options object, since they are
// not directly used to construct a Plugin instance. If set, need to be
// not directly used to construct a plugin instance. If set, need to be
// passed as options to the handler constructor instead.

@@ -52,3 +52,3 @@ const handlerOptionKeys = [

for (const [pluginName, pluginConfig] of Object.entries(options)) {
// Ensure that we have some valid configuration to pass to Plugin().
// Ensure that we have some valid configuration to pass to the plugin.
if (Object.keys(pluginConfig).length === 0) {

@@ -62,3 +62,5 @@ continue;

const name = pluginConfig.name;
const plugin = moduleRegistry.use('workbox-background-sync', 'Plugin');
const plugin = moduleRegistry.use(
'workbox-background-sync', 'BackgroundSyncPlugin');
pluginCode = `new ${plugin}(${JSON.stringify(name)}`;

@@ -76,3 +78,5 @@ if ('options' in pluginConfig) {

const opts = Object.assign({channelName}, pluginConfig.options);
const plugin = moduleRegistry.use('workbox-broadcast-update', 'Plugin');
const plugin = moduleRegistry.use(
'workbox-broadcast-update', 'BroadcastUpdatePlugin');
pluginCode = `new ${plugin}(${stringifyWithoutComments(opts)})`;

@@ -85,3 +89,4 @@

const plugin = moduleRegistry.use(
'workbox-cacheable-response', 'Plugin');
'workbox-cacheable-response', 'CacheableResponsePlugin');
pluginCode = `new ${plugin}(${stringifyWithoutComments(pluginConfig)})`;

@@ -93,3 +98,5 @@

case 'expiration': {
const plugin = moduleRegistry.use('workbox-expiration', 'Plugin');
const plugin = moduleRegistry.use(
'workbox-expiration', 'ExpirationPlugin');
pluginCode = `new ${plugin}(${stringifyWithoutComments(pluginConfig)})`;

@@ -119,3 +126,3 @@

module.exports = (moduleRegistry, runtimeCaching = []) => {
module.exports = (moduleRegistry, runtimeCaching) => {
return runtimeCaching.map((entry) => {

@@ -122,0 +129,0 @@ const method = entry.method || 'GET';

@@ -31,3 +31,3 @@ /*

*
* const cdnTransform = (manifestEntries) => {
* const cdnTransform = async (manifestEntries) => {
* const manifest = manifestEntries.map(entry => {

@@ -47,3 +47,3 @@ * const cdnOrigin = 'https://example.com';

*
* const removeRevisionTransform = (manifestEntries) => {
* const removeRevisionTransform = async (manifestEntries) => {
* const manifest = manifestEntries.map(entry => {

@@ -64,3 +64,3 @@ * const hashRegExp = /\.\w{8}\./;

* will be set to the current `compilation`.
* @return {module:workbox-build.ManifestTransformResult}
* @return {Promise<module:workbox-build.ManifestTransformResult>}
* The array of entries with the transformation applied, and optionally, any

@@ -72,3 +72,3 @@ * warnings that should be reported back to the build tool.

module.exports = ({
module.exports = async ({
additionalManifestEntries,

@@ -122,3 +122,3 @@ dontCacheBustURLsMatching,

for (const transform of transformsToApply) {
const result = transform(transformedManifest, transformParam);
const result = await transform(transformedManifest, transformParam);
if (!('manifest' in result)) {

@@ -125,0 +125,0 @@ throw new Error(errors['bad-manifest-transforms-return-value']);

@@ -42,15 +42,9 @@ /*

<% if (Array.isArray(manifestEntries)) {%>
<% if (Array.isArray(manifestEntries) && manifestEntries.length > 0) {%>
/**
* The workboxSW.precacheAndRoute() method efficiently caches and responds to
* The precacheAndRoute() method efficiently caches and responds to
* requests for URLs in the manifest.
* See https://goo.gl/S9QRab
*/
self.__precacheManifest = <%= JSON.stringify(manifestEntries, null, 2) %>.concat(self.__precacheManifest || []);
<%= use('workbox-precaching', 'precacheAndRoute') %>(self.__precacheManifest, <%= precacheOptionsString %>);
<% } else { %>
if (Array.isArray(self.__precacheManifest)) {
<%= use('workbox-precaching', 'precacheAndRoute') %>(self.__precacheManifest, <%= precacheOptionsString %>);
}
<% } %>
<%= use('workbox-precaching', 'precacheAndRoute') %>(<%= JSON.stringify(manifestEntries, null, 2) %>, <%= precacheOptionsString %>);
<% if (cleanupOutdatedCaches) { %><%= use('workbox-precaching', 'cleanupOutdatedCaches') %>();<% } %>

@@ -61,2 +55,3 @@ <% if (navigateFallback) { %><%= use('workbox-routing', 'registerRoute') %>(new <%= use('workbox-routing', 'NavigationRoute') %>(<%= use('workbox-precaching', 'createHandlerForURL') %>(<%= JSON.stringify(navigateFallback) %>)<% if (navigateFallbackWhitelist || navigateFallbackBlacklist) { %>, {

}<% } %>));<% } %>
<% } %>

@@ -63,0 +58,0 @@ <% if (runtimeCaching) { runtimeCaching.forEach(runtimeCachingString => {%><%= runtimeCachingString %><% });} %>

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc