workbox-build
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -10,2 +10,4 @@ // This will be the logic that powers both module and CLI | ||
* | ||
* **Install:** `npm install --save-dev workbox-build` | ||
* | ||
* To get a list of url's and a corresponding revision details, call either | ||
@@ -12,0 +14,0 @@ * `generateFileManifest` or `getFileManifestEntries()`. |
@@ -61,7 +61,7 @@ module.exports = { | ||
'injection-point-not-found': `Unable to find a place to inject the ` + | ||
`manifest. Please ensure that you have 'swlib.precache([])' ` + | ||
`manifest. Please ensure that you have 'workboxSW.precache([])' ` + | ||
`somewhere in your service worker file.`, | ||
'multiple-injection-points-found': `There can only be one injection point ` + | ||
`in your service worker file. Please ensure you only have one instance ` + | ||
`of 'swlib.precache([])' in your service worker file.`, | ||
`of 'workboxSW.precache([])' in your service worker file.`, | ||
'populating-sw-tmpl-failed': `Unable to generate service worker from ` + | ||
@@ -68,0 +68,0 @@ `template.`, |
@@ -105,9 +105,10 @@ const path = require('path'); | ||
let swlibPath; | ||
let workboxSWPath; | ||
let destDirectory = path.dirname(swDest); | ||
return copySWLib(destDirectory) | ||
.then((libPath) => { | ||
// If sw file is in build/sw.js, the swlib file will be build/swlib.***.js | ||
// So the sw.js file should import swlib.***.js (i.e. not include build/). | ||
swlibPath = path.relative(destDirectory, libPath); | ||
// If sw file is in build/sw.js, the workboxSW file will be | ||
// build/workboxSW.***.js. So the sw.js file should import workboxSW.***.js | ||
// (i.e. not include build/). | ||
workboxSWPath = path.relative(destDirectory, libPath); | ||
input.globIgnores.push(libPath); | ||
@@ -123,3 +124,3 @@ input.globIgnores.push(swDest); | ||
manifestEntries, | ||
swlibPath, | ||
workboxSWPath, | ||
globDirectory, | ||
@@ -126,0 +127,0 @@ input |
@@ -6,6 +6,7 @@ const errors = require('../errors'); | ||
module.exports = (outputDirectory) => { | ||
const swlibSrcPath = require.resolve('workbox-sw'); | ||
const swlibDestPath = path.join(outputDirectory, path.basename(swlibSrcPath)); | ||
return fse.copy(swlibSrcPath, swlibDestPath) | ||
.then(() => swlibDestPath) | ||
const workboxSWSrcPath = require.resolve('workbox-sw'); | ||
const workboxSWDestPath = path.join(outputDirectory, | ||
path.basename(workboxSWSrcPath)); | ||
return fse.copy(workboxSWSrcPath, workboxSWDestPath) | ||
.then(() => workboxSWDestPath) | ||
.catch((error) => { | ||
@@ -12,0 +13,0 @@ throw Error(`${errors['unable-to-copy-workbox-sw']} ${error}`); |
@@ -9,3 +9,3 @@ const path = require('path'); | ||
module.exports = | ||
(swSrc, manifestEntries, swlibPath, rootDirectory, options) => { | ||
(swSrc, manifestEntries, wbSWPathRelToSW, globDirectory, options) => { | ||
options = options || {}; | ||
@@ -33,24 +33,22 @@ try { | ||
.then((templateString) => { | ||
const relSwlibPath = path.relative(rootDirectory, swlibPath); | ||
const swlibOptions = {}; | ||
const workboxSWOptions = {}; | ||
if (options.cacheId) { | ||
swlibOptions.cacheId = options.cacheId; | ||
workboxSWOptions.cacheId = options.cacheId; | ||
} | ||
if (options.skipWaiting) { | ||
swlibOptions.skipWaiting = true; | ||
workboxSWOptions.skipWaiting = true; | ||
} | ||
if (options.handleFetch === false) { | ||
swlibOptions.handleFetch = false; | ||
workboxSWOptions.handleFetch = false; | ||
} | ||
if (options.clientsClaim) { | ||
swlibOptions.clientsClaim = true; | ||
workboxSWOptions.clientsClaim = true; | ||
} | ||
if (options.directoryIndex) { | ||
swlibOptions.directoryIndex = options.directoryIndex; | ||
workboxSWOptions.directoryIndex = options.directoryIndex; | ||
} | ||
if (options.ignoreUrlParametersMatching) { | ||
// JSON.stringify can't output regexes so instead we'll | ||
// inject it in the swlibOptionsString. | ||
swlibOptions.ignoreUrlParametersMatching = []; | ||
// inject it in the workboxSWOptionsString. | ||
workboxSWOptions.ignoreUrlParametersMatching = []; | ||
} | ||
@@ -65,5 +63,6 @@ let runtimeCaching = []; | ||
JSON.stringify(cachingEntry.options, null, 2) : ''; | ||
let stratString = `swlib.strategies.${handlerName}(${optionsString})`; | ||
let stratString = | ||
`workboxSW.strategies.${handlerName}(${optionsString})`; | ||
runtimeCaching.push( | ||
`swlib.router.registerRoute(${cachingEntry.urlPattern}, ` + | ||
`workboxSW.router.registerRoute(${cachingEntry.urlPattern}, ` + | ||
`${stratString});` | ||
@@ -74,3 +73,3 @@ ); | ||
runtimeCaching.push( | ||
`swlib.router.registerRoute(${cachingEntry.urlPattern}, ` + | ||
`workboxSW.router.registerRoute(${cachingEntry.urlPattern}, ` + | ||
`${handlerString});` | ||
@@ -83,8 +82,8 @@ ); | ||
try { | ||
let swlibOptionsString = ''; | ||
if (Object.keys(swlibOptions).length > 0) { | ||
swlibOptionsString = JSON.stringify(swlibOptions, null, 2); | ||
let workboxSWOptionsString = ''; | ||
if (Object.keys(workboxSWOptions).length > 0) { | ||
workboxSWOptionsString = JSON.stringify(workboxSWOptions, null, 2); | ||
} | ||
if (options.ignoreUrlParametersMatching) { | ||
swlibOptionsString = swlibOptionsString.replace( | ||
workboxSWOptionsString = workboxSWOptionsString.replace( | ||
'"ignoreUrlParametersMatching": []', | ||
@@ -97,6 +96,6 @@ `"ignoreUrlParametersMatching": [` + | ||
manifestEntries: manifestEntries, | ||
swlibPath: relSwlibPath, | ||
wbSWPathRelToSW, | ||
navigateFallback: options.navigateFallback, | ||
navigateFallbackWhitelist: options.navigateFallbackWhitelist, | ||
swlibOptionsString, | ||
workboxSWOptionsString, | ||
runtimeCaching, | ||
@@ -103,0 +102,0 @@ }).trim() + '\n'; |
{ | ||
"name": "workbox-build", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "This module can be used to generate a file manifest or service worker, that can be used with workbox-sw.", | ||
@@ -35,4 +35,4 @@ "keywords": [ | ||
"mkdirp": "^0.5.1", | ||
"workbox-sw": "^0.0.1" | ||
"workbox-sw": "^0.0.2" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51601
973
1
+ Addedworkbox-sw@0.0.2(transitive)
- Removedworkbox-sw@0.0.1(transitive)
Updatedworkbox-sw@^0.0.2