@serwist/build 8.4.4 → 9.0.0-preview.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/getManifest.js +6 -0
- package/dist/chunks/glob.js +58 -0
- package/dist/chunks/injectManifest.js +23 -0
- package/dist/chunks/serwist-config-error.js +54 -0
- package/dist/chunks/vite.js +7 -0
- package/dist/chunks/webpack.js +34 -0
- package/dist/get-manifest.d.ts +2 -1
- package/dist/get-manifest.d.ts.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +54 -1014
- package/dist/index.next.d.ts +3 -0
- package/dist/index.next.d.ts.map +1 -0
- package/dist/index.next.js +38 -0
- package/dist/inject-manifest.d.ts +2 -1
- package/dist/inject-manifest.d.ts.map +1 -0
- package/dist/lib/additional-precache-entries-transform.d.ts +6 -5
- package/dist/lib/additional-precache-entries-transform.d.ts.map +1 -0
- package/dist/lib/errors.d.ts +1 -2
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/escape-regexp.d.ts +2 -1
- package/dist/lib/escape-regexp.d.ts.map +1 -0
- package/dist/lib/get-composite-details.d.ts +2 -1
- package/dist/lib/get-composite-details.d.ts.map +1 -0
- package/dist/lib/get-file-details.d.ts +2 -1
- package/dist/lib/get-file-details.d.ts.map +1 -0
- package/dist/lib/get-file-hash.d.ts +1 -0
- package/dist/lib/get-file-hash.d.ts.map +1 -0
- package/dist/lib/get-file-manifest-entries.d.ts +1 -0
- package/dist/lib/get-file-manifest-entries.d.ts.map +1 -0
- package/dist/lib/get-file-size.d.ts +1 -0
- package/dist/lib/get-file-size.d.ts.map +1 -0
- package/dist/lib/get-source-map-url.d.ts +1 -0
- package/dist/lib/get-source-map-url.d.ts.map +1 -0
- package/dist/lib/get-string-details.d.ts +1 -0
- package/dist/lib/get-string-details.d.ts.map +1 -0
- package/dist/lib/get-string-hash.d.ts +1 -0
- package/dist/lib/get-string-hash.d.ts.map +1 -0
- package/dist/lib/maximum-size-transform.d.ts +1 -0
- package/dist/lib/maximum-size-transform.d.ts.map +1 -0
- package/dist/lib/modify-url-prefix-transform.d.ts +1 -0
- package/dist/lib/modify-url-prefix-transform.d.ts.map +1 -0
- package/dist/lib/no-revision-for-urls-matching-transform.d.ts +1 -0
- package/dist/lib/no-revision-for-urls-matching-transform.d.ts.map +1 -0
- package/dist/lib/rebase-path.d.ts +1 -0
- package/dist/lib/rebase-path.d.ts.map +1 -0
- package/dist/lib/replace-and-update-source-map.d.ts +1 -0
- package/dist/lib/replace-and-update-source-map.d.ts.map +1 -0
- package/dist/lib/serwist-config-error.d.ts +7 -0
- package/dist/lib/serwist-config-error.d.ts.map +1 -0
- package/dist/lib/transform-manifest.d.ts +2 -1
- package/dist/lib/transform-manifest.d.ts.map +1 -0
- package/dist/lib/translate-url-to-sourcemap-paths.d.ts +1 -0
- package/dist/lib/translate-url-to-sourcemap-paths.d.ts.map +1 -0
- package/dist/lib/validate-next-options.d.ts +3 -0
- package/dist/lib/validate-next-options.d.ts.map +1 -0
- package/dist/lib/validate-options.d.ts +6 -8
- package/dist/lib/validate-options.d.ts.map +1 -0
- package/dist/schema/assertType.d.ts +3 -0
- package/dist/schema/assertType.d.ts.map +1 -0
- package/dist/schema/base.d.ts +169 -0
- package/dist/schema/base.d.ts.map +1 -0
- package/dist/schema/getManifest.d.ts +187 -0
- package/dist/schema/getManifest.d.ts.map +1 -0
- package/dist/schema/glob.d.ts +35 -0
- package/dist/schema/glob.d.ts.map +1 -0
- package/dist/schema/injectManifest.d.ts +206 -0
- package/dist/schema/injectManifest.d.ts.map +1 -0
- package/dist/schema/manifestEntry.d.ts +15 -0
- package/dist/schema/manifestEntry.d.ts.map +1 -0
- package/dist/schema/manifestTransform.d.ts +121 -0
- package/dist/schema/manifestTransform.d.ts.map +1 -0
- package/dist/schema/next.d.ts +243 -0
- package/dist/schema/next.d.ts.map +1 -0
- package/dist/schema/swDest.d.ts +16 -0
- package/dist/schema/swDest.d.ts.map +1 -0
- package/dist/schema/validationErrorMap.d.ts +3 -0
- package/dist/schema/validationErrorMap.d.ts.map +1 -0
- package/dist/schema/vite.d.ts +196 -0
- package/dist/schema/vite.d.ts.map +1 -0
- package/dist/schema/webpack.d.ts +231 -0
- package/dist/schema/webpack.d.ts.map +1 -0
- package/dist/types.d.ts +147 -175
- package/dist/types.d.ts.map +1 -0
- package/package.json +43 -29
- package/src/_types.js +112 -0
- package/src/get-manifest.ts +33 -0
- package/src/index.next.ts +3 -0
- package/{dist/index.d.cts → src/index.ts} +27 -2
- package/src/inject-manifest.ts +140 -0
- package/src/lib/additional-precache-entries-transform.ts +58 -0
- package/src/lib/errors.ts +99 -0
- package/src/lib/escape-regexp.ts +12 -0
- package/src/lib/get-composite-details.ts +31 -0
- package/src/lib/get-file-details.ts +68 -0
- package/src/lib/get-file-hash.ts +21 -0
- package/src/lib/get-file-manifest-entries.ts +126 -0
- package/src/lib/get-file-size.ts +23 -0
- package/src/lib/get-source-map-url.ts +17 -0
- package/src/lib/get-string-details.ts +18 -0
- package/src/lib/get-string-hash.ts +15 -0
- package/src/lib/maximum-size-transform.ts +29 -0
- package/src/lib/modify-url-prefix-transform.ts +55 -0
- package/src/lib/no-revision-for-urls-matching-transform.ts +32 -0
- package/src/lib/rebase-path.ts +22 -0
- package/src/lib/replace-and-update-source-map.ts +122 -0
- package/src/lib/serwist-config-error.ts +6 -0
- package/src/lib/transform-manifest.ts +158 -0
- package/src/lib/translate-url-to-sourcemap-paths.ts +38 -0
- package/src/lib/validate-next-options.ts +14 -0
- package/src/lib/validate-options.ts +47 -0
- package/src/schema/assertType.ts +5 -0
- package/src/schema/base.ts +20 -0
- package/src/schema/getManifest.ts +13 -0
- package/src/schema/glob.ts +41 -0
- package/src/schema/injectManifest.ts +25 -0
- package/src/schema/manifestEntry.ts +9 -0
- package/src/schema/manifestTransform.ts +15 -0
- package/src/schema/next.ts +33 -0
- package/src/schema/swDest.ts +20 -0
- package/src/schema/validationErrorMap.ts +36 -0
- package/src/schema/vite.ts +18 -0
- package/src/schema/webpack.ts +47 -0
- package/src/types.ts +407 -0
- package/dist/index.cjs +0 -1632
- package/dist/lib/cdn-utils.d.ts +0 -1
- package/dist/lib/copy-serwist-libraries.d.ts +0 -16
- package/dist/schema/index.d.ts +0 -605
package/dist/index.js
CHANGED
|
@@ -6,9 +6,10 @@ import crypto from 'crypto';
|
|
|
6
6
|
import { glob } from 'glob';
|
|
7
7
|
import upath from 'upath';
|
|
8
8
|
import fse from 'fs-extra';
|
|
9
|
-
import
|
|
10
|
-
import
|
|
9
|
+
import prettyBytes from 'pretty-bytes';
|
|
10
|
+
import { v as validationErrorMap, S as SerwistConfigError } from './chunks/serwist-config-error.js';
|
|
11
11
|
import { SourceMapGenerator, SourceMapConsumer } from 'source-map';
|
|
12
|
+
import 'zod';
|
|
12
13
|
|
|
13
14
|
const errors = {
|
|
14
15
|
"unable-to-get-rootdir": "Unable to get the root directory of your web app.",
|
|
@@ -76,10 +77,6 @@ const errors = {
|
|
|
76
77
|
'templatedURLs'.`,
|
|
77
78
|
"invalid-runtime-caching": oneLine`The 'runtimeCaching' parameter must an an
|
|
78
79
|
array of objects with at least a 'urlPattern' and 'handler'.`,
|
|
79
|
-
"static-file-globs-deprecated": oneLine`'staticFileGlobs' is deprecated.
|
|
80
|
-
Please use 'globPatterns' instead.`,
|
|
81
|
-
"dynamic-url-deprecated": oneLine`'dynamicURLToDependencies' is deprecated.
|
|
82
|
-
Please use 'templatedURLs' instead.`,
|
|
83
80
|
"urlPattern-is-required": oneLine`The 'urlPattern' option is required when using
|
|
84
81
|
'runtimeCaching'.`,
|
|
85
82
|
"handler-is-required": oneLine`The 'handler' option is required when using
|
|
@@ -104,7 +101,7 @@ const errors = {
|
|
|
104
101
|
an array of functions.`
|
|
105
102
|
};
|
|
106
103
|
|
|
107
|
-
|
|
104
|
+
const getCompositeDetails = (compositeURL, dependencyDetails)=>{
|
|
108
105
|
let totalSize = 0;
|
|
109
106
|
let compositeHash = "";
|
|
110
107
|
for (const fileDetails of dependencyDetails){
|
|
@@ -119,7 +116,7 @@ function getCompositeDetails(compositeURL, dependencyDetails) {
|
|
|
119
116
|
hash: hashOfHashes,
|
|
120
117
|
size: totalSize
|
|
121
118
|
};
|
|
122
|
-
}
|
|
119
|
+
};
|
|
123
120
|
|
|
124
121
|
function getStringHash(input) {
|
|
125
122
|
const md5 = crypto.createHash("md5");
|
|
@@ -194,13 +191,11 @@ function getStringDetails(url, str) {
|
|
|
194
191
|
};
|
|
195
192
|
}
|
|
196
193
|
|
|
197
|
-
|
|
194
|
+
const additionalPrecacheEntriesTransform = (additionalPrecacheEntries)=>{
|
|
198
195
|
return (manifest)=>{
|
|
199
196
|
const warnings = [];
|
|
200
197
|
const stringEntries = new Set();
|
|
201
198
|
for (const additionalEntry of additionalPrecacheEntries){
|
|
202
|
-
// Warn about either a string or an object that lacks a revision property.
|
|
203
|
-
// (An object with a revision property set to null is okay.)
|
|
204
199
|
if (typeof additionalEntry === "string") {
|
|
205
200
|
stringEntries.add(additionalEntry);
|
|
206
201
|
manifest.push({
|
|
@@ -229,111 +224,7 @@ function additionalPrecacheEntriesTransform(additionalPrecacheEntries) {
|
|
|
229
224
|
warnings
|
|
230
225
|
};
|
|
231
226
|
};
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
const BYTE_UNITS = [
|
|
235
|
-
'B',
|
|
236
|
-
'kB',
|
|
237
|
-
'MB',
|
|
238
|
-
'GB',
|
|
239
|
-
'TB',
|
|
240
|
-
'PB',
|
|
241
|
-
'EB',
|
|
242
|
-
'ZB',
|
|
243
|
-
'YB'
|
|
244
|
-
];
|
|
245
|
-
const BIBYTE_UNITS = [
|
|
246
|
-
'B',
|
|
247
|
-
'KiB',
|
|
248
|
-
'MiB',
|
|
249
|
-
'GiB',
|
|
250
|
-
'TiB',
|
|
251
|
-
'PiB',
|
|
252
|
-
'EiB',
|
|
253
|
-
'ZiB',
|
|
254
|
-
'YiB'
|
|
255
|
-
];
|
|
256
|
-
const BIT_UNITS = [
|
|
257
|
-
'b',
|
|
258
|
-
'kbit',
|
|
259
|
-
'Mbit',
|
|
260
|
-
'Gbit',
|
|
261
|
-
'Tbit',
|
|
262
|
-
'Pbit',
|
|
263
|
-
'Ebit',
|
|
264
|
-
'Zbit',
|
|
265
|
-
'Ybit'
|
|
266
|
-
];
|
|
267
|
-
const BIBIT_UNITS = [
|
|
268
|
-
'b',
|
|
269
|
-
'kibit',
|
|
270
|
-
'Mibit',
|
|
271
|
-
'Gibit',
|
|
272
|
-
'Tibit',
|
|
273
|
-
'Pibit',
|
|
274
|
-
'Eibit',
|
|
275
|
-
'Zibit',
|
|
276
|
-
'Yibit'
|
|
277
|
-
];
|
|
278
|
-
/*
|
|
279
|
-
Formats the given number using `Number#toLocaleString`.
|
|
280
|
-
- If locale is a string, the value is expected to be a locale-key (for example: `de`).
|
|
281
|
-
- If locale is true, the system default locale is used for translation.
|
|
282
|
-
- If no value for locale is specified, the number is returned unmodified.
|
|
283
|
-
*/ const toLocaleString = (number, locale, options)=>{
|
|
284
|
-
let result = number;
|
|
285
|
-
if (typeof locale === 'string' || Array.isArray(locale)) {
|
|
286
|
-
result = number.toLocaleString(locale, options);
|
|
287
|
-
} else if (locale === true || options !== undefined) {
|
|
288
|
-
result = number.toLocaleString(undefined, options);
|
|
289
|
-
}
|
|
290
|
-
return result;
|
|
291
227
|
};
|
|
292
|
-
function prettyBytes(number, options) {
|
|
293
|
-
if (!Number.isFinite(number)) {
|
|
294
|
-
throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
|
|
295
|
-
}
|
|
296
|
-
options = {
|
|
297
|
-
bits: false,
|
|
298
|
-
binary: false,
|
|
299
|
-
space: true,
|
|
300
|
-
...options
|
|
301
|
-
};
|
|
302
|
-
const UNITS = options.bits ? options.binary ? BIBIT_UNITS : BIT_UNITS : options.binary ? BIBYTE_UNITS : BYTE_UNITS;
|
|
303
|
-
const separator = options.space ? ' ' : '';
|
|
304
|
-
if (options.signed && number === 0) {
|
|
305
|
-
return ` 0${separator}${UNITS[0]}`;
|
|
306
|
-
}
|
|
307
|
-
const isNegative = number < 0;
|
|
308
|
-
const prefix = isNegative ? '-' : options.signed ? '+' : '';
|
|
309
|
-
if (isNegative) {
|
|
310
|
-
number = -number;
|
|
311
|
-
}
|
|
312
|
-
let localeOptions;
|
|
313
|
-
if (options.minimumFractionDigits !== undefined) {
|
|
314
|
-
localeOptions = {
|
|
315
|
-
minimumFractionDigits: options.minimumFractionDigits
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
if (options.maximumFractionDigits !== undefined) {
|
|
319
|
-
localeOptions = {
|
|
320
|
-
maximumFractionDigits: options.maximumFractionDigits,
|
|
321
|
-
...localeOptions
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
if (number < 1) {
|
|
325
|
-
const numberString = toLocaleString(number, options.locale, localeOptions);
|
|
326
|
-
return prefix + numberString + separator + UNITS[0];
|
|
327
|
-
}
|
|
328
|
-
const exponent = Math.min(Math.floor(options.binary ? Math.log(number) / Math.log(1024) : Math.log10(number) / 3), UNITS.length - 1);
|
|
329
|
-
number /= (options.binary ? 1024 : 1000) ** exponent;
|
|
330
|
-
if (!localeOptions) {
|
|
331
|
-
number = number.toPrecision(3);
|
|
332
|
-
}
|
|
333
|
-
const numberString = toLocaleString(Number(number), options.locale, localeOptions);
|
|
334
|
-
const unit = UNITS[exponent];
|
|
335
|
-
return prefix + numberString + separator + unit;
|
|
336
|
-
}
|
|
337
228
|
|
|
338
229
|
function maximumSizeTransform(maximumFileSizeToCacheInBytes) {
|
|
339
230
|
return (originalManifest)=>{
|
|
@@ -352,23 +243,14 @@ function maximumSizeTransform(maximumFileSizeToCacheInBytes) {
|
|
|
352
243
|
};
|
|
353
244
|
}
|
|
354
245
|
|
|
355
|
-
|
|
356
|
-
Copyright 2019 Google LLC
|
|
357
|
-
|
|
358
|
-
Use of this source code is governed by an MIT-style
|
|
359
|
-
license that can be found in the LICENSE file or at
|
|
360
|
-
https://opensource.org/licenses/MIT.
|
|
361
|
-
*/ // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
|
|
362
|
-
function escapeRegExp(str) {
|
|
246
|
+
const escapeRegExp = (str)=>{
|
|
363
247
|
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
364
|
-
}
|
|
248
|
+
};
|
|
365
249
|
|
|
366
250
|
function modifyURLPrefixTransform(modifyURLPrefix) {
|
|
367
251
|
if (!modifyURLPrefix || typeof modifyURLPrefix !== "object" || Array.isArray(modifyURLPrefix)) {
|
|
368
252
|
throw new Error(errors["modify-url-prefix-bad-prefixes"]);
|
|
369
253
|
}
|
|
370
|
-
// If there are no entries in modifyURLPrefix, just return an identity
|
|
371
|
-
// function as a shortcut.
|
|
372
254
|
if (Object.keys(modifyURLPrefix).length === 0) {
|
|
373
255
|
return (manifest)=>{
|
|
374
256
|
return {
|
|
@@ -381,12 +263,8 @@ function modifyURLPrefixTransform(modifyURLPrefix) {
|
|
|
381
263
|
throw new Error(errors["modify-url-prefix-bad-prefixes"]);
|
|
382
264
|
}
|
|
383
265
|
}
|
|
384
|
-
// Escape the user input so it's safe to use in a regex.
|
|
385
266
|
const safeModifyURLPrefixes = Object.keys(modifyURLPrefix).map(escapeRegExp);
|
|
386
|
-
// Join all the `modifyURLPrefix` keys so a single regex can be used.
|
|
387
267
|
const prefixMatchesStrings = safeModifyURLPrefixes.join("|");
|
|
388
|
-
// Add `^` to the front the prefix matches so it only matches the start of
|
|
389
|
-
// a string.
|
|
390
268
|
const modifyRegex = new RegExp(`^(${prefixMatchesStrings})`);
|
|
391
269
|
return (originalManifest)=>{
|
|
392
270
|
const manifest = originalManifest.map((entry)=>{
|
|
@@ -434,8 +312,6 @@ async function transformManifest({ additionalPrecacheEntries, dontCacheBustURLsM
|
|
|
434
312
|
};
|
|
435
313
|
}
|
|
436
314
|
const allWarnings = [];
|
|
437
|
-
// Take the array of fileDetail objects and convert it into an array of
|
|
438
|
-
// {url, revision, size} objects, with \ replaced with /.
|
|
439
315
|
const normalizedManifest = fileDetails.map((fileDetails)=>{
|
|
440
316
|
return {
|
|
441
317
|
url: fileDetails.file.replace(/\\/g, "/"),
|
|
@@ -453,11 +329,9 @@ async function transformManifest({ additionalPrecacheEntries, dontCacheBustURLsM
|
|
|
453
329
|
if (dontCacheBustURLsMatching) {
|
|
454
330
|
transformsToApply.push(noRevisionForURLsMatchingTransform(dontCacheBustURLsMatching));
|
|
455
331
|
}
|
|
456
|
-
// Run any manifestTransforms functions second-to-last.
|
|
457
332
|
if (manifestTransforms) {
|
|
458
333
|
transformsToApply.push(...manifestTransforms);
|
|
459
334
|
}
|
|
460
|
-
// Run additionalPrecacheEntriesTransform last.
|
|
461
335
|
if (additionalPrecacheEntries) {
|
|
462
336
|
transformsToApply.push(additionalPrecacheEntriesTransform(additionalPrecacheEntries));
|
|
463
337
|
}
|
|
@@ -470,13 +344,10 @@ async function transformManifest({ additionalPrecacheEntries, dontCacheBustURLsM
|
|
|
470
344
|
transformedManifest = result.manifest;
|
|
471
345
|
allWarnings.push(...result.warnings || []);
|
|
472
346
|
}
|
|
473
|
-
// Generate some metadata about the manifest before we clear out the size
|
|
474
|
-
// properties from each entry.
|
|
475
347
|
const count = transformedManifest.length;
|
|
476
348
|
let size = 0;
|
|
477
349
|
for (const manifestEntry of transformedManifest){
|
|
478
350
|
size += manifestEntry.size || 0;
|
|
479
|
-
// biome-ignore lint/performance/noDelete: I don't understand this part yet.
|
|
480
351
|
delete manifestEntry.size;
|
|
481
352
|
}
|
|
482
353
|
return {
|
|
@@ -517,8 +388,6 @@ async function getFileManifestEntries({ additionalPrecacheEntries, dontCacheBust
|
|
|
517
388
|
}
|
|
518
389
|
}
|
|
519
390
|
} catch (error) {
|
|
520
|
-
// If there's an exception thrown while globbing, then report
|
|
521
|
-
// it back as a warning, and don't consider it fatal.
|
|
522
391
|
if (error instanceof Error && error.message) {
|
|
523
392
|
warnings.push(error.message);
|
|
524
393
|
}
|
|
@@ -569,839 +438,60 @@ async function getFileManifestEntries({ additionalPrecacheEntries, dontCacheBust
|
|
|
569
438
|
return transformedManifest;
|
|
570
439
|
}
|
|
571
440
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
$ref: "#/definitions/ManifestEntry"
|
|
582
|
-
},
|
|
583
|
-
{
|
|
584
|
-
type: "string"
|
|
585
|
-
}
|
|
586
|
-
]
|
|
587
|
-
}
|
|
588
|
-
},
|
|
589
|
-
dontCacheBustURLsMatching: {
|
|
590
|
-
description: "Assets that match this will be assumed to be uniquely versioned via their\nURL, and exempted from the normal HTTP cache-busting that's done when\npopulating the precache. While not required, it's recommended that if your\nexisting build process already inserts a `[hash]` value into each filename,\nyou provide a RegExp that will detect that, as it will reduce the bandwidth\nconsumed when precaching.",
|
|
591
|
-
$ref: "#/definitions/RegExp"
|
|
592
|
-
},
|
|
593
|
-
manifestTransforms: {
|
|
594
|
-
description: "One or more functions which will be applied sequentially against the\ngenerated manifest. If `modifyURLPrefix` or `dontCacheBustURLsMatching` are\nalso specified, their corresponding transformations will be applied first.",
|
|
595
|
-
type: "array",
|
|
596
|
-
items: {}
|
|
597
|
-
},
|
|
598
|
-
maximumFileSizeToCacheInBytes: {
|
|
599
|
-
description: "This value can be used to determine the maximum size of files that will be\nprecached. This prevents you from inadvertently precaching very large files\nthat might have accidentally matched one of your patterns.",
|
|
600
|
-
"default": 2097152,
|
|
601
|
-
type: "number"
|
|
602
|
-
},
|
|
603
|
-
modifyURLPrefix: {
|
|
604
|
-
description: "An object mapping string prefixes to replacement string values. This can be\nused to, e.g., remove or add a path prefix from a manifest entry if your\nweb hosting setup doesn't match your local filesystem setup. As an\nalternative with more flexibility, you can use the `manifestTransforms`\noption and provide a function that modifies the entries in the manifest\nusing whatever logic you provide.\n\nExample usage:\n\n```\n// Replace a '/dist/' prefix with '/', and also prepend\n// '/static' to every URL.\nmodifyURLPrefix: {\n '/dist/': '/',\n '': '/static',\n}\n```",
|
|
605
|
-
type: "object",
|
|
606
|
-
additionalProperties: {
|
|
607
|
-
type: "string"
|
|
608
|
-
}
|
|
609
|
-
},
|
|
610
|
-
globFollow: {
|
|
611
|
-
description: "Determines whether or not symlinks are followed when generating the\nprecache manifest. For more information, see the definition of `follow` in\nthe `glob` [documentation](https://github.com/isaacs/node-glob#options).",
|
|
612
|
-
"default": true,
|
|
613
|
-
type: "boolean"
|
|
614
|
-
},
|
|
615
|
-
globIgnores: {
|
|
616
|
-
description: "A set of patterns matching files to always exclude when generating the\nprecache manifest. For more information, see the definition of `ignore` in\nthe `glob` [documentation](https://github.com/isaacs/node-glob#options).",
|
|
617
|
-
"default": [
|
|
618
|
-
"**/node_modules/**/*"
|
|
619
|
-
],
|
|
620
|
-
type: "array",
|
|
621
|
-
items: {
|
|
622
|
-
type: "string"
|
|
623
|
-
}
|
|
624
|
-
},
|
|
625
|
-
globPatterns: {
|
|
626
|
-
description: "Files matching any of these patterns will be included in the precache\nmanifest. For more information, see the\n[`glob` primer](https://github.com/isaacs/node-glob#glob-primer).",
|
|
627
|
-
"default": [
|
|
628
|
-
"**/*.{js,css,html}"
|
|
629
|
-
],
|
|
630
|
-
type: "array",
|
|
631
|
-
items: {
|
|
632
|
-
type: "string"
|
|
633
|
-
}
|
|
634
|
-
},
|
|
635
|
-
globStrict: {
|
|
636
|
-
description: "If true, an error reading a directory when generating a precache manifest\nwill cause the build to fail. If false, the problematic directory will be\nskipped. For more information, see the definition of `strict` in the `glob`\n[documentation](https://github.com/isaacs/node-glob#options).",
|
|
637
|
-
"default": true,
|
|
638
|
-
type: "boolean"
|
|
639
|
-
},
|
|
640
|
-
templatedURLs: {
|
|
641
|
-
description: "If a URL is rendered based on some server-side logic, its contents may\ndepend on multiple files or on some other unique string value. The keys in\nthis object are server-rendered URLs. If the values are an array of\nstrings, they will be interpreted as `glob` patterns, and the contents of\nany files matching the patterns will be used to uniquely version the URL.\nIf used with a single string, it will be interpreted as unique versioning\ninformation that you've generated for a given URL.",
|
|
642
|
-
type: "object",
|
|
643
|
-
additionalProperties: {
|
|
644
|
-
anyOf: [
|
|
645
|
-
{
|
|
646
|
-
type: "array",
|
|
647
|
-
items: {
|
|
648
|
-
type: "string"
|
|
649
|
-
}
|
|
650
|
-
},
|
|
651
|
-
{
|
|
652
|
-
type: "string"
|
|
653
|
-
}
|
|
654
|
-
]
|
|
655
|
-
}
|
|
656
|
-
},
|
|
657
|
-
globDirectory: {
|
|
658
|
-
description: "The local directory you wish to match `globPatterns` against. The path is\nrelative to the current directory.",
|
|
659
|
-
type: "string"
|
|
660
|
-
}
|
|
661
|
-
};
|
|
662
|
-
var required$3 = [
|
|
663
|
-
"globDirectory"
|
|
664
|
-
];
|
|
665
|
-
var definitions$3 = {
|
|
666
|
-
ManifestEntry: {
|
|
667
|
-
type: "object",
|
|
668
|
-
properties: {
|
|
669
|
-
integrity: {
|
|
670
|
-
type: "string"
|
|
671
|
-
},
|
|
672
|
-
revision: {
|
|
673
|
-
type: [
|
|
674
|
-
"null",
|
|
675
|
-
"string"
|
|
676
|
-
]
|
|
677
|
-
},
|
|
678
|
-
url: {
|
|
679
|
-
type: "string"
|
|
680
|
-
}
|
|
681
|
-
},
|
|
682
|
-
additionalProperties: false,
|
|
683
|
-
required: [
|
|
684
|
-
"revision",
|
|
685
|
-
"url"
|
|
686
|
-
]
|
|
687
|
-
},
|
|
688
|
-
"RegExp": {
|
|
689
|
-
type: "object",
|
|
690
|
-
properties: {
|
|
691
|
-
source: {
|
|
692
|
-
type: "string"
|
|
693
|
-
},
|
|
694
|
-
global: {
|
|
695
|
-
type: "boolean"
|
|
696
|
-
},
|
|
697
|
-
ignoreCase: {
|
|
698
|
-
type: "boolean"
|
|
699
|
-
},
|
|
700
|
-
multiline: {
|
|
701
|
-
type: "boolean"
|
|
702
|
-
},
|
|
703
|
-
lastIndex: {
|
|
704
|
-
type: "number"
|
|
705
|
-
},
|
|
706
|
-
flags: {
|
|
707
|
-
type: "string"
|
|
708
|
-
},
|
|
709
|
-
sticky: {
|
|
710
|
-
type: "boolean"
|
|
711
|
-
},
|
|
712
|
-
unicode: {
|
|
713
|
-
type: "boolean"
|
|
714
|
-
},
|
|
715
|
-
dotAll: {
|
|
716
|
-
type: "boolean"
|
|
717
|
-
}
|
|
718
|
-
},
|
|
719
|
-
additionalProperties: false,
|
|
720
|
-
required: [
|
|
721
|
-
"dotAll",
|
|
722
|
-
"flags",
|
|
723
|
-
"global",
|
|
724
|
-
"ignoreCase",
|
|
725
|
-
"lastIndex",
|
|
726
|
-
"multiline",
|
|
727
|
-
"source",
|
|
728
|
-
"sticky",
|
|
729
|
-
"unicode"
|
|
730
|
-
]
|
|
731
|
-
}
|
|
732
|
-
};
|
|
733
|
-
var $schema$3 = "http://json-schema.org/draft-07/schema#";
|
|
734
|
-
var getManifestOptionsSchema = {
|
|
735
|
-
additionalProperties: additionalProperties$3,
|
|
736
|
-
type: type$3,
|
|
737
|
-
properties: properties$3,
|
|
738
|
-
required: required$3,
|
|
739
|
-
definitions: definitions$3,
|
|
740
|
-
$schema: $schema$3
|
|
741
|
-
};
|
|
742
|
-
|
|
743
|
-
var additionalProperties$2 = false;
|
|
744
|
-
var type$2 = "object";
|
|
745
|
-
var properties$2 = {
|
|
746
|
-
additionalPrecacheEntries: {
|
|
747
|
-
description: "A list of entries to be precached, in addition to any entries that are\ngenerated as part of the build configuration.",
|
|
748
|
-
type: "array",
|
|
749
|
-
items: {
|
|
750
|
-
anyOf: [
|
|
751
|
-
{
|
|
752
|
-
$ref: "#/definitions/ManifestEntry"
|
|
753
|
-
},
|
|
754
|
-
{
|
|
755
|
-
type: "string"
|
|
756
|
-
}
|
|
757
|
-
]
|
|
758
|
-
}
|
|
759
|
-
},
|
|
760
|
-
dontCacheBustURLsMatching: {
|
|
761
|
-
description: "Assets that match this will be assumed to be uniquely versioned via their\nURL, and exempted from the normal HTTP cache-busting that's done when\npopulating the precache. While not required, it's recommended that if your\nexisting build process already inserts a `[hash]` value into each filename,\nyou provide a RegExp that will detect that, as it will reduce the bandwidth\nconsumed when precaching.",
|
|
762
|
-
$ref: "#/definitions/RegExp"
|
|
763
|
-
},
|
|
764
|
-
manifestTransforms: {
|
|
765
|
-
description: "One or more functions which will be applied sequentially against the\ngenerated manifest. If `modifyURLPrefix` or `dontCacheBustURLsMatching` are\nalso specified, their corresponding transformations will be applied first.",
|
|
766
|
-
type: "array",
|
|
767
|
-
items: {}
|
|
768
|
-
},
|
|
769
|
-
maximumFileSizeToCacheInBytes: {
|
|
770
|
-
description: "This value can be used to determine the maximum size of files that will be\nprecached. This prevents you from inadvertently precaching very large files\nthat might have accidentally matched one of your patterns.",
|
|
771
|
-
"default": 2097152,
|
|
772
|
-
type: "number"
|
|
773
|
-
},
|
|
774
|
-
modifyURLPrefix: {
|
|
775
|
-
description: "An object mapping string prefixes to replacement string values. This can be\nused to, e.g., remove or add a path prefix from a manifest entry if your\nweb hosting setup doesn't match your local filesystem setup. As an\nalternative with more flexibility, you can use the `manifestTransforms`\noption and provide a function that modifies the entries in the manifest\nusing whatever logic you provide.\n\nExample usage:\n\n```\n// Replace a '/dist/' prefix with '/', and also prepend\n// '/static' to every URL.\nmodifyURLPrefix: {\n '/dist/': '/',\n '': '/static',\n}\n```",
|
|
776
|
-
type: "object",
|
|
777
|
-
additionalProperties: {
|
|
778
|
-
type: "string"
|
|
779
|
-
}
|
|
780
|
-
},
|
|
781
|
-
globFollow: {
|
|
782
|
-
description: "Determines whether or not symlinks are followed when generating the\nprecache manifest. For more information, see the definition of `follow` in\nthe `glob` [documentation](https://github.com/isaacs/node-glob#options).",
|
|
783
|
-
"default": true,
|
|
784
|
-
type: "boolean"
|
|
785
|
-
},
|
|
786
|
-
globIgnores: {
|
|
787
|
-
description: "A set of patterns matching files to always exclude when generating the\nprecache manifest. For more information, see the definition of `ignore` in\nthe `glob` [documentation](https://github.com/isaacs/node-glob#options).",
|
|
788
|
-
"default": [
|
|
789
|
-
"**/node_modules/**/*"
|
|
790
|
-
],
|
|
791
|
-
type: "array",
|
|
792
|
-
items: {
|
|
793
|
-
type: "string"
|
|
794
|
-
}
|
|
795
|
-
},
|
|
796
|
-
globPatterns: {
|
|
797
|
-
description: "Files matching any of these patterns will be included in the precache\nmanifest. For more information, see the\n[`glob` primer](https://github.com/isaacs/node-glob#glob-primer).",
|
|
798
|
-
"default": [
|
|
799
|
-
"**/*.{js,css,html}"
|
|
800
|
-
],
|
|
801
|
-
type: "array",
|
|
802
|
-
items: {
|
|
803
|
-
type: "string"
|
|
804
|
-
}
|
|
805
|
-
},
|
|
806
|
-
globStrict: {
|
|
807
|
-
description: "If true, an error reading a directory when generating a precache manifest\nwill cause the build to fail. If false, the problematic directory will be\nskipped. For more information, see the definition of `strict` in the `glob`\n[documentation](https://github.com/isaacs/node-glob#options).",
|
|
808
|
-
"default": true,
|
|
809
|
-
type: "boolean"
|
|
810
|
-
},
|
|
811
|
-
templatedURLs: {
|
|
812
|
-
description: "If a URL is rendered based on some server-side logic, its contents may\ndepend on multiple files or on some other unique string value. The keys in\nthis object are server-rendered URLs. If the values are an array of\nstrings, they will be interpreted as `glob` patterns, and the contents of\nany files matching the patterns will be used to uniquely version the URL.\nIf used with a single string, it will be interpreted as unique versioning\ninformation that you've generated for a given URL.",
|
|
813
|
-
type: "object",
|
|
814
|
-
additionalProperties: {
|
|
815
|
-
anyOf: [
|
|
816
|
-
{
|
|
817
|
-
type: "array",
|
|
818
|
-
items: {
|
|
819
|
-
type: "string"
|
|
820
|
-
}
|
|
821
|
-
},
|
|
822
|
-
{
|
|
823
|
-
type: "string"
|
|
824
|
-
}
|
|
825
|
-
]
|
|
826
|
-
}
|
|
827
|
-
},
|
|
828
|
-
injectionPoint: {
|
|
829
|
-
description: "The string to find inside of the `swSrc` file. Once found, it will be\nreplaced by the generated precache manifest.",
|
|
830
|
-
"default": "self.__SW_MANIFEST",
|
|
831
|
-
type: "string"
|
|
832
|
-
},
|
|
833
|
-
swSrc: {
|
|
834
|
-
description: "The path and filename of the service worker file that will be read during\nthe build process, relative to the current working directory.",
|
|
835
|
-
type: "string"
|
|
836
|
-
},
|
|
837
|
-
swDest: {
|
|
838
|
-
description: "The path and filename of the service worker file that will be created by\nthe build process, relative to the current working directory. It must end\nin '.js'.",
|
|
839
|
-
type: "string"
|
|
840
|
-
},
|
|
841
|
-
globDirectory: {
|
|
842
|
-
description: "The local directory you wish to match `globPatterns` against. The path is\nrelative to the current directory.",
|
|
843
|
-
type: "string"
|
|
844
|
-
},
|
|
845
|
-
disablePrecacheManifest: {
|
|
846
|
-
description: "Whether the precache manifest should be set to `undefined`.",
|
|
847
|
-
"default": false,
|
|
848
|
-
type: "boolean"
|
|
849
|
-
}
|
|
850
|
-
};
|
|
851
|
-
var required$2 = [
|
|
852
|
-
"globDirectory",
|
|
853
|
-
"swDest",
|
|
854
|
-
"swSrc"
|
|
855
|
-
];
|
|
856
|
-
var definitions$2 = {
|
|
857
|
-
ManifestEntry: {
|
|
858
|
-
type: "object",
|
|
859
|
-
properties: {
|
|
860
|
-
integrity: {
|
|
861
|
-
type: "string"
|
|
862
|
-
},
|
|
863
|
-
revision: {
|
|
864
|
-
type: [
|
|
865
|
-
"null",
|
|
866
|
-
"string"
|
|
867
|
-
]
|
|
868
|
-
},
|
|
869
|
-
url: {
|
|
870
|
-
type: "string"
|
|
871
|
-
}
|
|
872
|
-
},
|
|
873
|
-
additionalProperties: false,
|
|
874
|
-
required: [
|
|
875
|
-
"revision",
|
|
876
|
-
"url"
|
|
877
|
-
]
|
|
878
|
-
},
|
|
879
|
-
"RegExp": {
|
|
880
|
-
type: "object",
|
|
881
|
-
properties: {
|
|
882
|
-
source: {
|
|
883
|
-
type: "string"
|
|
884
|
-
},
|
|
885
|
-
global: {
|
|
886
|
-
type: "boolean"
|
|
887
|
-
},
|
|
888
|
-
ignoreCase: {
|
|
889
|
-
type: "boolean"
|
|
890
|
-
},
|
|
891
|
-
multiline: {
|
|
892
|
-
type: "boolean"
|
|
893
|
-
},
|
|
894
|
-
lastIndex: {
|
|
895
|
-
type: "number"
|
|
896
|
-
},
|
|
897
|
-
flags: {
|
|
898
|
-
type: "string"
|
|
899
|
-
},
|
|
900
|
-
sticky: {
|
|
901
|
-
type: "boolean"
|
|
902
|
-
},
|
|
903
|
-
unicode: {
|
|
904
|
-
type: "boolean"
|
|
905
|
-
},
|
|
906
|
-
dotAll: {
|
|
907
|
-
type: "boolean"
|
|
908
|
-
}
|
|
909
|
-
},
|
|
910
|
-
additionalProperties: false,
|
|
911
|
-
required: [
|
|
912
|
-
"dotAll",
|
|
913
|
-
"flags",
|
|
914
|
-
"global",
|
|
915
|
-
"ignoreCase",
|
|
916
|
-
"lastIndex",
|
|
917
|
-
"multiline",
|
|
918
|
-
"source",
|
|
919
|
-
"sticky",
|
|
920
|
-
"unicode"
|
|
921
|
-
]
|
|
922
|
-
}
|
|
923
|
-
};
|
|
924
|
-
var $schema$2 = "http://json-schema.org/draft-07/schema#";
|
|
925
|
-
var injectManifestOptionsSchema = {
|
|
926
|
-
additionalProperties: additionalProperties$2,
|
|
927
|
-
type: type$2,
|
|
928
|
-
properties: properties$2,
|
|
929
|
-
required: required$2,
|
|
930
|
-
definitions: definitions$2,
|
|
931
|
-
$schema: $schema$2
|
|
932
|
-
};
|
|
933
|
-
|
|
934
|
-
var additionalProperties$1 = false;
|
|
935
|
-
var type$1 = "object";
|
|
936
|
-
var properties$1 = {
|
|
937
|
-
additionalPrecacheEntries: {
|
|
938
|
-
description: "A list of entries to be precached, in addition to any entries that are\ngenerated as part of the build configuration.",
|
|
939
|
-
type: "array",
|
|
940
|
-
items: {
|
|
941
|
-
anyOf: [
|
|
942
|
-
{
|
|
943
|
-
$ref: "#/definitions/ManifestEntry"
|
|
944
|
-
},
|
|
945
|
-
{
|
|
946
|
-
type: "string"
|
|
947
|
-
}
|
|
948
|
-
]
|
|
949
|
-
}
|
|
950
|
-
},
|
|
951
|
-
dontCacheBustURLsMatching: {
|
|
952
|
-
description: "Assets that match this will be assumed to be uniquely versioned via their\nURL, and exempted from the normal HTTP cache-busting that's done when\npopulating the precache. While not required, it's recommended that if your\nexisting build process already inserts a `[hash]` value into each filename,\nyou provide a RegExp that will detect that, as it will reduce the bandwidth\nconsumed when precaching.",
|
|
953
|
-
$ref: "#/definitions/RegExp"
|
|
954
|
-
},
|
|
955
|
-
manifestTransforms: {
|
|
956
|
-
description: "One or more functions which will be applied sequentially against the\ngenerated manifest. If `modifyURLPrefix` or `dontCacheBustURLsMatching` are\nalso specified, their corresponding transformations will be applied first.",
|
|
957
|
-
type: "array",
|
|
958
|
-
items: {}
|
|
959
|
-
},
|
|
960
|
-
maximumFileSizeToCacheInBytes: {
|
|
961
|
-
description: "This value can be used to determine the maximum size of files that will be\nprecached. This prevents you from inadvertently precaching very large files\nthat might have accidentally matched one of your patterns.",
|
|
962
|
-
"default": 2097152,
|
|
963
|
-
type: "number"
|
|
964
|
-
},
|
|
965
|
-
modifyURLPrefix: {
|
|
966
|
-
description: "An object mapping string prefixes to replacement string values. This can be\nused to, e.g., remove or add a path prefix from a manifest entry if your\nweb hosting setup doesn't match your local filesystem setup. As an\nalternative with more flexibility, you can use the `manifestTransforms`\noption and provide a function that modifies the entries in the manifest\nusing whatever logic you provide.\n\nExample usage:\n\n```\n// Replace a '/dist/' prefix with '/', and also prepend\n// '/static' to every URL.\nmodifyURLPrefix: {\n '/dist/': '/',\n '': '/static',\n}\n```",
|
|
967
|
-
type: "object",
|
|
968
|
-
additionalProperties: {
|
|
969
|
-
type: "string"
|
|
970
|
-
}
|
|
971
|
-
},
|
|
972
|
-
globFollow: {
|
|
973
|
-
description: "Determines whether or not symlinks are followed when generating the\nprecache manifest. For more information, see the definition of `follow` in\nthe `glob` [documentation](https://github.com/isaacs/node-glob#options).",
|
|
974
|
-
"default": true,
|
|
975
|
-
type: "boolean"
|
|
976
|
-
},
|
|
977
|
-
globIgnores: {
|
|
978
|
-
description: "A set of patterns matching files to always exclude when generating the\nprecache manifest. For more information, see the definition of `ignore` in\nthe `glob` [documentation](https://github.com/isaacs/node-glob#options).",
|
|
979
|
-
"default": [
|
|
980
|
-
"**/node_modules/**/*"
|
|
981
|
-
],
|
|
982
|
-
type: "array",
|
|
983
|
-
items: {
|
|
984
|
-
type: "string"
|
|
985
|
-
}
|
|
986
|
-
},
|
|
987
|
-
globPatterns: {
|
|
988
|
-
description: "Files matching any of these patterns will be included in the precache\nmanifest. For more information, see the\n[`glob` primer](https://github.com/isaacs/node-glob#glob-primer).",
|
|
989
|
-
"default": [
|
|
990
|
-
"**/*.{js,css,html}"
|
|
991
|
-
],
|
|
992
|
-
type: "array",
|
|
993
|
-
items: {
|
|
994
|
-
type: "string"
|
|
995
|
-
}
|
|
996
|
-
},
|
|
997
|
-
globStrict: {
|
|
998
|
-
description: "If true, an error reading a directory when generating a precache manifest\nwill cause the build to fail. If false, the problematic directory will be\nskipped. For more information, see the definition of `strict` in the `glob`\n[documentation](https://github.com/isaacs/node-glob#options).",
|
|
999
|
-
"default": true,
|
|
1000
|
-
type: "boolean"
|
|
1001
|
-
},
|
|
1002
|
-
templatedURLs: {
|
|
1003
|
-
description: "If a URL is rendered based on some server-side logic, its contents may\ndepend on multiple files or on some other unique string value. The keys in\nthis object are server-rendered URLs. If the values are an array of\nstrings, they will be interpreted as `glob` patterns, and the contents of\nany files matching the patterns will be used to uniquely version the URL.\nIf used with a single string, it will be interpreted as unique versioning\ninformation that you've generated for a given URL.",
|
|
1004
|
-
type: "object",
|
|
1005
|
-
additionalProperties: {
|
|
1006
|
-
anyOf: [
|
|
1007
|
-
{
|
|
1008
|
-
type: "array",
|
|
1009
|
-
items: {
|
|
1010
|
-
type: "string"
|
|
1011
|
-
}
|
|
1012
|
-
},
|
|
1013
|
-
{
|
|
1014
|
-
type: "string"
|
|
1015
|
-
}
|
|
1016
|
-
]
|
|
1017
|
-
}
|
|
1018
|
-
},
|
|
1019
|
-
injectionPoint: {
|
|
1020
|
-
description: "The string to find inside of the `swSrc` file. Once found, it will be\nreplaced by the generated precache manifest.",
|
|
1021
|
-
"default": "self.__SW_MANIFEST",
|
|
1022
|
-
type: "string"
|
|
1023
|
-
},
|
|
1024
|
-
swSrc: {
|
|
1025
|
-
description: "The path and filename of the service worker file that will be read during\nthe build process, relative to the current working directory.",
|
|
1026
|
-
type: "string"
|
|
1027
|
-
},
|
|
1028
|
-
swDest: {
|
|
1029
|
-
description: "The path and filename of the service worker file that will be created by\nthe build process, relative to the current working directory. It must end\nin '.js'.",
|
|
1030
|
-
type: "string"
|
|
1031
|
-
},
|
|
1032
|
-
globDirectory: {
|
|
1033
|
-
description: "The local directory you wish to match `globPatterns` against. The path is\nrelative to the current directory.",
|
|
1034
|
-
type: "string"
|
|
1035
|
-
},
|
|
1036
|
-
disablePrecacheManifest: {
|
|
1037
|
-
description: "Whether the precache manifest should be set to `undefined`.",
|
|
1038
|
-
"default": false,
|
|
1039
|
-
type: "boolean"
|
|
1040
|
-
}
|
|
1041
|
-
};
|
|
1042
|
-
var required$1 = [
|
|
1043
|
-
"globDirectory",
|
|
1044
|
-
"swDest",
|
|
1045
|
-
"swSrc"
|
|
1046
|
-
];
|
|
1047
|
-
var definitions$1 = {
|
|
1048
|
-
ManifestEntry: {
|
|
1049
|
-
type: "object",
|
|
1050
|
-
properties: {
|
|
1051
|
-
integrity: {
|
|
1052
|
-
type: "string"
|
|
1053
|
-
},
|
|
1054
|
-
revision: {
|
|
1055
|
-
type: [
|
|
1056
|
-
"null",
|
|
1057
|
-
"string"
|
|
1058
|
-
]
|
|
1059
|
-
},
|
|
1060
|
-
url: {
|
|
1061
|
-
type: "string"
|
|
1062
|
-
}
|
|
1063
|
-
},
|
|
1064
|
-
additionalProperties: false,
|
|
1065
|
-
required: [
|
|
1066
|
-
"revision",
|
|
1067
|
-
"url"
|
|
1068
|
-
]
|
|
1069
|
-
},
|
|
1070
|
-
"RegExp": {
|
|
1071
|
-
type: "object",
|
|
1072
|
-
properties: {
|
|
1073
|
-
source: {
|
|
1074
|
-
type: "string"
|
|
1075
|
-
},
|
|
1076
|
-
global: {
|
|
1077
|
-
type: "boolean"
|
|
1078
|
-
},
|
|
1079
|
-
ignoreCase: {
|
|
1080
|
-
type: "boolean"
|
|
1081
|
-
},
|
|
1082
|
-
multiline: {
|
|
1083
|
-
type: "boolean"
|
|
1084
|
-
},
|
|
1085
|
-
lastIndex: {
|
|
1086
|
-
type: "number"
|
|
1087
|
-
},
|
|
1088
|
-
flags: {
|
|
1089
|
-
type: "string"
|
|
1090
|
-
},
|
|
1091
|
-
sticky: {
|
|
1092
|
-
type: "boolean"
|
|
1093
|
-
},
|
|
1094
|
-
unicode: {
|
|
1095
|
-
type: "boolean"
|
|
1096
|
-
},
|
|
1097
|
-
dotAll: {
|
|
1098
|
-
type: "boolean"
|
|
1099
|
-
}
|
|
1100
|
-
},
|
|
1101
|
-
additionalProperties: false,
|
|
1102
|
-
required: [
|
|
1103
|
-
"dotAll",
|
|
1104
|
-
"flags",
|
|
1105
|
-
"global",
|
|
1106
|
-
"ignoreCase",
|
|
1107
|
-
"lastIndex",
|
|
1108
|
-
"multiline",
|
|
1109
|
-
"source",
|
|
1110
|
-
"sticky",
|
|
1111
|
-
"unicode"
|
|
1112
|
-
]
|
|
441
|
+
const validateGetManifestOptions = async (input)=>{
|
|
442
|
+
const result = await (await import('./chunks/getManifest.js')).getManifestOptions.spa(input, {
|
|
443
|
+
errorMap: validationErrorMap
|
|
444
|
+
});
|
|
445
|
+
if (!result.success) {
|
|
446
|
+
throw new SerwistConfigError({
|
|
447
|
+
moduleName: "@serwist/build",
|
|
448
|
+
message: JSON.stringify(result.error.format(), null, 2)
|
|
449
|
+
});
|
|
1113
450
|
}
|
|
451
|
+
return result.data;
|
|
1114
452
|
};
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
};
|
|
1124
|
-
|
|
1125
|
-
var additionalProperties = false;
|
|
1126
|
-
var type = "object";
|
|
1127
|
-
var properties = {
|
|
1128
|
-
additionalPrecacheEntries: {
|
|
1129
|
-
description: "A list of entries to be precached, in addition to any entries that are\ngenerated as part of the build configuration.",
|
|
1130
|
-
type: "array",
|
|
1131
|
-
items: {
|
|
1132
|
-
anyOf: [
|
|
1133
|
-
{
|
|
1134
|
-
$ref: "#/definitions/ManifestEntry"
|
|
1135
|
-
},
|
|
1136
|
-
{
|
|
1137
|
-
type: "string"
|
|
1138
|
-
}
|
|
1139
|
-
]
|
|
1140
|
-
}
|
|
1141
|
-
},
|
|
1142
|
-
dontCacheBustURLsMatching: {
|
|
1143
|
-
description: "Assets that match this will be assumed to be uniquely versioned via their\nURL, and exempted from the normal HTTP cache-busting that's done when\npopulating the precache. While not required, it's recommended that if your\nexisting build process already inserts a `[hash]` value into each filename,\nyou provide a RegExp that will detect that, as it will reduce the bandwidth\nconsumed when precaching.",
|
|
1144
|
-
$ref: "#/definitions/RegExp"
|
|
1145
|
-
},
|
|
1146
|
-
manifestTransforms: {
|
|
1147
|
-
description: "One or more functions which will be applied sequentially against the\ngenerated manifest. If `modifyURLPrefix` or `dontCacheBustURLsMatching` are\nalso specified, their corresponding transformations will be applied first.",
|
|
1148
|
-
type: "array",
|
|
1149
|
-
items: {}
|
|
1150
|
-
},
|
|
1151
|
-
maximumFileSizeToCacheInBytes: {
|
|
1152
|
-
description: "This value can be used to determine the maximum size of files that will be\nprecached. This prevents you from inadvertently precaching very large files\nthat might have accidentally matched one of your patterns.",
|
|
1153
|
-
"default": 2097152,
|
|
1154
|
-
type: "number"
|
|
1155
|
-
},
|
|
1156
|
-
modifyURLPrefix: {
|
|
1157
|
-
description: "An object mapping string prefixes to replacement string values. This can be\nused to, e.g., remove or add a path prefix from a manifest entry if your\nweb hosting setup doesn't match your local filesystem setup. As an\nalternative with more flexibility, you can use the `manifestTransforms`\noption and provide a function that modifies the entries in the manifest\nusing whatever logic you provide.\n\nExample usage:\n\n```\n// Replace a '/dist/' prefix with '/', and also prepend\n// '/static' to every URL.\nmodifyURLPrefix: {\n '/dist/': '/',\n '': '/static',\n}\n```",
|
|
1158
|
-
type: "object",
|
|
1159
|
-
additionalProperties: {
|
|
1160
|
-
type: "string"
|
|
1161
|
-
}
|
|
1162
|
-
},
|
|
1163
|
-
chunks: {
|
|
1164
|
-
description: "One or more chunk names whose corresponding output files should be included\nin the precache manifest.",
|
|
1165
|
-
type: "array",
|
|
1166
|
-
items: {
|
|
1167
|
-
type: "string"
|
|
1168
|
-
}
|
|
1169
|
-
},
|
|
1170
|
-
exclude: {
|
|
1171
|
-
description: "One or more specifiers used to exclude assets from the precache manifest.\nThis is interpreted following\n[the same rules](https://webpack.js.org/configuration/module/#condition)\nas `webpack`'s standard `exclude` option.\nIf not provided, the default value is `[/\\.map$/, /^manifest.*\\.js$]`.",
|
|
1172
|
-
type: "array",
|
|
1173
|
-
items: {}
|
|
1174
|
-
},
|
|
1175
|
-
excludeChunks: {
|
|
1176
|
-
description: "One or more chunk names whose corresponding output files should be excluded\nfrom the precache manifest.",
|
|
1177
|
-
type: "array",
|
|
1178
|
-
items: {
|
|
1179
|
-
type: "string"
|
|
1180
|
-
}
|
|
1181
|
-
},
|
|
1182
|
-
include: {
|
|
1183
|
-
description: "One or more specifiers used to include assets in the precache manifest.\nThis is interpreted following\n[the same rules](https://webpack.js.org/configuration/module/#condition)\nas `webpack`'s standard `include` option.",
|
|
1184
|
-
type: "array",
|
|
1185
|
-
items: {}
|
|
1186
|
-
},
|
|
1187
|
-
mode: {
|
|
1188
|
-
description: "If set to 'production', then an optimized service worker bundle that\nexcludes debugging info will be produced. If not explicitly configured\nhere, the `mode` value configured in the current `webpack` compilation\nwill be used.",
|
|
1189
|
-
type: [
|
|
1190
|
-
"null",
|
|
1191
|
-
"string"
|
|
1192
|
-
]
|
|
1193
|
-
},
|
|
1194
|
-
injectionPoint: {
|
|
1195
|
-
description: "The string to find inside of the `swSrc` file. Once found, it will be\nreplaced by the generated precache manifest.",
|
|
1196
|
-
"default": "self.__SW_MANIFEST",
|
|
1197
|
-
type: "string"
|
|
1198
|
-
},
|
|
1199
|
-
swSrc: {
|
|
1200
|
-
description: "The path and filename of the service worker file that will be read during\nthe build process, relative to the current working directory.",
|
|
1201
|
-
type: "string"
|
|
1202
|
-
},
|
|
1203
|
-
compileSrc: {
|
|
1204
|
-
description: "When `true` (the default), the `swSrc` file will be compiled by webpack.\nWhen `false`, compilation will not occur (and `webpackCompilationPlugins`\ncan't be used.) Set to `false` if you want to inject the manifest into,\ne.g., a JSON file.",
|
|
1205
|
-
"default": true,
|
|
1206
|
-
type: "boolean"
|
|
1207
|
-
},
|
|
1208
|
-
swDest: {
|
|
1209
|
-
description: "The asset name of the service worker file that will be created by this\nplugin. If omitted, the name will be based on the `swSrc` name.",
|
|
1210
|
-
type: "string"
|
|
1211
|
-
},
|
|
1212
|
-
webpackCompilationPlugins: {
|
|
1213
|
-
description: "Optional `webpack` plugins that will be used when compiling the `swSrc`\ninput file. Only valid if `compileSrc` is `true`.",
|
|
1214
|
-
type: "array",
|
|
1215
|
-
items: {}
|
|
1216
|
-
},
|
|
1217
|
-
disablePrecacheManifest: {
|
|
1218
|
-
description: "Whether the precache manifest should be set to `undefined`.",
|
|
1219
|
-
"default": false,
|
|
1220
|
-
type: "boolean"
|
|
453
|
+
const validateInjectManifestOptions = async (input)=>{
|
|
454
|
+
const result = await (await import('./chunks/injectManifest.js').then(function (n) { return n.a; })).injectManifestOptions.spa(input, {
|
|
455
|
+
errorMap: validationErrorMap
|
|
456
|
+
});
|
|
457
|
+
if (!result.success) {
|
|
458
|
+
throw new SerwistConfigError({
|
|
459
|
+
moduleName: "@serwist/build",
|
|
460
|
+
message: JSON.stringify(result.error.format(), null, 2)
|
|
461
|
+
});
|
|
1221
462
|
}
|
|
463
|
+
return result.data;
|
|
1222
464
|
};
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
},
|
|
1233
|
-
revision: {
|
|
1234
|
-
type: [
|
|
1235
|
-
"null",
|
|
1236
|
-
"string"
|
|
1237
|
-
]
|
|
1238
|
-
},
|
|
1239
|
-
url: {
|
|
1240
|
-
type: "string"
|
|
1241
|
-
}
|
|
1242
|
-
},
|
|
1243
|
-
additionalProperties: false,
|
|
1244
|
-
required: [
|
|
1245
|
-
"revision",
|
|
1246
|
-
"url"
|
|
1247
|
-
]
|
|
1248
|
-
},
|
|
1249
|
-
"RegExp": {
|
|
1250
|
-
type: "object",
|
|
1251
|
-
properties: {
|
|
1252
|
-
source: {
|
|
1253
|
-
type: "string"
|
|
1254
|
-
},
|
|
1255
|
-
global: {
|
|
1256
|
-
type: "boolean"
|
|
1257
|
-
},
|
|
1258
|
-
ignoreCase: {
|
|
1259
|
-
type: "boolean"
|
|
1260
|
-
},
|
|
1261
|
-
multiline: {
|
|
1262
|
-
type: "boolean"
|
|
1263
|
-
},
|
|
1264
|
-
lastIndex: {
|
|
1265
|
-
type: "number"
|
|
1266
|
-
},
|
|
1267
|
-
flags: {
|
|
1268
|
-
type: "string"
|
|
1269
|
-
},
|
|
1270
|
-
sticky: {
|
|
1271
|
-
type: "boolean"
|
|
1272
|
-
},
|
|
1273
|
-
unicode: {
|
|
1274
|
-
type: "boolean"
|
|
1275
|
-
},
|
|
1276
|
-
dotAll: {
|
|
1277
|
-
type: "boolean"
|
|
1278
|
-
}
|
|
1279
|
-
},
|
|
1280
|
-
additionalProperties: false,
|
|
1281
|
-
required: [
|
|
1282
|
-
"dotAll",
|
|
1283
|
-
"flags",
|
|
1284
|
-
"global",
|
|
1285
|
-
"ignoreCase",
|
|
1286
|
-
"lastIndex",
|
|
1287
|
-
"multiline",
|
|
1288
|
-
"source",
|
|
1289
|
-
"sticky",
|
|
1290
|
-
"unicode"
|
|
1291
|
-
]
|
|
465
|
+
const validateWebpackInjectManifestOptions = async (input)=>{
|
|
466
|
+
const result = await (await import('./chunks/webpack.js')).webpackInjectManifestOptions.spa(input, {
|
|
467
|
+
errorMap: validationErrorMap
|
|
468
|
+
});
|
|
469
|
+
if (!result.success) {
|
|
470
|
+
throw new SerwistConfigError({
|
|
471
|
+
moduleName: "@serwist/webpack-plugin",
|
|
472
|
+
message: JSON.stringify(result.error.format(), null, 2)
|
|
473
|
+
});
|
|
1292
474
|
}
|
|
475
|
+
return result.data;
|
|
1293
476
|
};
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
type: type,
|
|
1298
|
-
properties: properties,
|
|
1299
|
-
required: required,
|
|
1300
|
-
definitions: definitions,
|
|
1301
|
-
$schema: $schema
|
|
1302
|
-
};
|
|
1303
|
-
|
|
1304
|
-
const optionsSchemas = {
|
|
1305
|
-
GetManifest: getManifestOptionsSchema,
|
|
1306
|
-
InjectManifest: injectManifestOptionsSchema,
|
|
1307
|
-
WebpackInjectManifest: webpackInjectManifestOptionsSchema,
|
|
1308
|
-
ViteInjectManifest: viteInjectManifestOptionsSchema
|
|
1309
|
-
};
|
|
1310
|
-
|
|
1311
|
-
const ajv = new Ajv({
|
|
1312
|
-
useDefaults: true
|
|
1313
|
-
});
|
|
1314
|
-
const DEFAULT_EXCLUDE_VALUE = [
|
|
1315
|
-
/\.map$/,
|
|
1316
|
-
/^manifest.*\.js$/
|
|
1317
|
-
];
|
|
1318
|
-
class SerwistConfigError extends Error {
|
|
1319
|
-
constructor(message){
|
|
1320
|
-
super(message);
|
|
1321
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
1322
|
-
}
|
|
1323
|
-
}
|
|
1324
|
-
// Some methods need to do follow-up validation using the JSON schema,
|
|
1325
|
-
// so return both the validated options and then schema.
|
|
1326
|
-
function validate(input, methodName) {
|
|
1327
|
-
// Don't mutate input: https://github.com/GoogleChrome/workbox/issues/2158
|
|
1328
|
-
const inputCopy = Object.assign({}, input);
|
|
1329
|
-
const jsonSchema = optionsSchemas[methodName];
|
|
1330
|
-
const validate = ajv.compile(jsonSchema);
|
|
1331
|
-
if (validate(inputCopy)) {
|
|
1332
|
-
// All methods support manifestTransforms, so validate it here.
|
|
1333
|
-
ensureValidManifestTransforms(inputCopy);
|
|
1334
|
-
return [
|
|
1335
|
-
inputCopy,
|
|
1336
|
-
jsonSchema
|
|
1337
|
-
];
|
|
1338
|
-
}
|
|
1339
|
-
const betterErrors = betterAjvErrors({
|
|
1340
|
-
basePath: methodName,
|
|
1341
|
-
data: input,
|
|
1342
|
-
errors: validate.errors,
|
|
1343
|
-
// This is needed as JSONSchema6 is expected, but JSONSchemaType works.
|
|
1344
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
1345
|
-
schema: jsonSchema
|
|
477
|
+
const validateViteInjectManifestOptions = async (input)=>{
|
|
478
|
+
const result = await (await import('./chunks/vite.js')).viteInjectManifestOptions.spa(input, {
|
|
479
|
+
errorMap: validationErrorMap
|
|
1346
480
|
});
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
if ("manifestTransforms" in options && !(Array.isArray(options.manifestTransforms) && options.manifestTransforms.every((item)=>typeof item === "function"))) {
|
|
1353
|
-
throw new SerwistConfigError(errors["manifest-transforms"]);
|
|
481
|
+
if (!result.success) {
|
|
482
|
+
throw new SerwistConfigError({
|
|
483
|
+
moduleName: "@serwist/vite",
|
|
484
|
+
message: JSON.stringify(result.error.format(), null, 2)
|
|
485
|
+
});
|
|
1354
486
|
}
|
|
1355
|
-
|
|
1356
|
-
function validateGetManifestOptions(input) {
|
|
1357
|
-
const [validatedOptions] = validate(input, "GetManifest");
|
|
1358
|
-
return validatedOptions;
|
|
1359
|
-
}
|
|
1360
|
-
function validateInjectManifestOptions(input) {
|
|
1361
|
-
const [validatedOptions] = validate(input, "InjectManifest");
|
|
1362
|
-
return validatedOptions;
|
|
1363
|
-
}
|
|
1364
|
-
function validateWebpackInjectManifestOptions(input) {
|
|
1365
|
-
const inputWithExcludeDefault = Object.assign({
|
|
1366
|
-
// Make a copy, as exclude can be mutated when used.
|
|
1367
|
-
exclude: Array.from(DEFAULT_EXCLUDE_VALUE)
|
|
1368
|
-
}, input);
|
|
1369
|
-
const [validatedOptions] = validate(inputWithExcludeDefault, "WebpackInjectManifest");
|
|
1370
|
-
return validatedOptions;
|
|
1371
|
-
}
|
|
1372
|
-
const validateViteInjectManifestOptions = (input)=>{
|
|
1373
|
-
const [validatedOptions] = validate(input, "ViteInjectManifest");
|
|
1374
|
-
return validatedOptions;
|
|
487
|
+
return result.data;
|
|
1375
488
|
};
|
|
1376
489
|
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
* manifest", along with details about the number of entries and their size,
|
|
1380
|
-
* based on the options you provide.
|
|
1381
|
-
*
|
|
1382
|
-
* ```
|
|
1383
|
-
* // The following lists some common options; see the rest of the documentation
|
|
1384
|
-
* // for the full set of options and defaults.
|
|
1385
|
-
* const {count, manifestEntries, size, warnings} = await getManifest({
|
|
1386
|
-
* dontCacheBustURLsMatching: [new RegExp('...')],
|
|
1387
|
-
* globDirectory: '...',
|
|
1388
|
-
* globPatterns: ['...', '...'],
|
|
1389
|
-
* maximumFileSizeToCacheInBytes: ...,
|
|
1390
|
-
* });
|
|
1391
|
-
* ```
|
|
1392
|
-
*/ async function getManifest(config) {
|
|
1393
|
-
const options = validateGetManifestOptions(config);
|
|
490
|
+
const getManifest = async (config)=>{
|
|
491
|
+
const options = await validateGetManifestOptions(config);
|
|
1394
492
|
return await getFileManifestEntries(options);
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
|
-
/*
|
|
1398
|
-
Copyright 2022 Google LLC
|
|
493
|
+
};
|
|
1399
494
|
|
|
1400
|
-
Use of this source code is governed by an MIT-style
|
|
1401
|
-
license that can be found in the LICENSE file or at
|
|
1402
|
-
https://opensource.org/licenses/MIT.
|
|
1403
|
-
*/ // Adapted from https://github.com/lydell/source-map-url/blob/master/source-map-url.js
|
|
1404
|
-
// See https://github.com/GoogleChrome/workbox/issues/3019
|
|
1405
495
|
const innerRegex = /[#@] sourceMappingURL=([^\s'"]*)/;
|
|
1406
496
|
const regex = RegExp(`(?:/\\*(?:\\s*\r?\n(?://)?)?(?:${innerRegex.source})\\s*\\*/|//(?:${innerRegex.source}))\\s*`);
|
|
1407
497
|
function getSourceMapURL(srcContents) {
|
|
@@ -1410,24 +500,13 @@ function getSourceMapURL(srcContents) {
|
|
|
1410
500
|
}
|
|
1411
501
|
|
|
1412
502
|
function rebasePath({ baseDirectory, file }) {
|
|
1413
|
-
// The initial path is relative to the current directory, so make it absolute.
|
|
1414
503
|
const absolutePath = upath.resolve(file);
|
|
1415
|
-
// Convert the absolute path so that it's relative to the baseDirectory.
|
|
1416
504
|
const relativePath = upath.relative(baseDirectory, absolutePath);
|
|
1417
|
-
// Remove any leading ./ as it won't work in a glob pattern.
|
|
1418
505
|
const normalizedPath = upath.normalize(relativePath);
|
|
1419
506
|
return normalizedPath;
|
|
1420
507
|
}
|
|
1421
508
|
|
|
1422
|
-
|
|
1423
|
-
* Adapted from https://github.com/nsams/sourcemap-aware-replace, with modern
|
|
1424
|
-
* JavaScript updates, along with additional properties copied from originalMap.
|
|
1425
|
-
*
|
|
1426
|
-
* @param options
|
|
1427
|
-
* @returns An object containing both
|
|
1428
|
-
* originalSource with the replacement applied, and the modified originalMap.
|
|
1429
|
-
* @private
|
|
1430
|
-
*/ async function replaceAndUpdateSourceMap({ jsFilename, originalMap, originalSource, replaceString, searchString }) {
|
|
509
|
+
async function replaceAndUpdateSourceMap({ jsFilename, originalMap, originalSource, replaceString, searchString }) {
|
|
1431
510
|
const generator = new SourceMapGenerator({
|
|
1432
511
|
file: jsFilename
|
|
1433
512
|
});
|
|
@@ -1477,8 +556,6 @@ function rebasePath({ baseDirectory, file }) {
|
|
|
1477
556
|
return mapping;
|
|
1478
557
|
});
|
|
1479
558
|
consumer.destroy();
|
|
1480
|
-
// JSON.parse returns any.
|
|
1481
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
1482
559
|
const updatedSourceMap = Object.assign(JSON.parse(generator.toString()), {
|
|
1483
560
|
names: originalMap.names,
|
|
1484
561
|
sourceRoot: originalMap.sourceRoot,
|
|
@@ -1511,34 +588,8 @@ function translateURLToSourcemapPaths(url, swSrc, swDest) {
|
|
|
1511
588
|
};
|
|
1512
589
|
}
|
|
1513
590
|
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
* manifest", based on the options you provide.
|
|
1517
|
-
*
|
|
1518
|
-
* The manifest is injected into the `swSrc` file, and the placeholder string
|
|
1519
|
-
* `injectionPoint` determines where in the file the manifest should go.
|
|
1520
|
-
*
|
|
1521
|
-
* The final service worker file, with the manifest injected, is written to
|
|
1522
|
-
* disk at `swDest`.
|
|
1523
|
-
*
|
|
1524
|
-
* This method will not compile or bundle your `swSrc` file; it just handles
|
|
1525
|
-
* injecting the manifest.
|
|
1526
|
-
*
|
|
1527
|
-
* ```
|
|
1528
|
-
* // The following lists some common options; see the rest of the documentation
|
|
1529
|
-
* // for the full set of options and defaults.
|
|
1530
|
-
* const {count, size, warnings} = await injectManifest({
|
|
1531
|
-
* dontCacheBustURLsMatching: [new RegExp('...')],
|
|
1532
|
-
* globDirectory: '...',
|
|
1533
|
-
* globPatterns: ['...', '...'],
|
|
1534
|
-
* maximumFileSizeToCacheInBytes: ...,
|
|
1535
|
-
* swDest: '...',
|
|
1536
|
-
* swSrc: '...',
|
|
1537
|
-
* });
|
|
1538
|
-
* ```
|
|
1539
|
-
*/ async function injectManifest(config) {
|
|
1540
|
-
const options = validateInjectManifestOptions(config);
|
|
1541
|
-
// Make sure we leave swSrc and swDest out of the precache manifest.
|
|
591
|
+
const injectManifest = async (config)=>{
|
|
592
|
+
const options = await validateInjectManifestOptions(config);
|
|
1542
593
|
for (const file of [
|
|
1543
594
|
options.swSrc,
|
|
1544
595
|
options.swDest
|
|
@@ -1557,7 +608,6 @@ function translateURLToSourcemapPaths(url, swSrc, swDest) {
|
|
|
1557
608
|
throw new Error(`${errors["invalid-sw-src"]} ${error instanceof Error && error.message ? error.message : ""}`);
|
|
1558
609
|
}
|
|
1559
610
|
const injectionResults = swFileContents.match(globalRegexp);
|
|
1560
|
-
// See https://github.com/GoogleChrome/workbox/issues/2230
|
|
1561
611
|
const injectionPoint = options.injectionPoint ? options.injectionPoint : "";
|
|
1562
612
|
if (!injectionResults) {
|
|
1563
613
|
if (upath.resolve(options.swSrc) === upath.resolve(options.swDest)) {
|
|
@@ -1569,17 +619,10 @@ function translateURLToSourcemapPaths(url, swSrc, swDest) {
|
|
|
1569
619
|
const manifestString = manifestEntries === undefined ? "undefined" : stringify(manifestEntries);
|
|
1570
620
|
const filesToWrite = {};
|
|
1571
621
|
const url = getSourceMapURL(swFileContents);
|
|
1572
|
-
// See https://github.com/GoogleChrome/workbox/issues/2957
|
|
1573
622
|
const { destPath, srcPath, warning } = translateURLToSourcemapPaths(url, options.swSrc, options.swDest);
|
|
1574
623
|
if (warning) {
|
|
1575
624
|
warnings.push(warning);
|
|
1576
625
|
}
|
|
1577
|
-
// If our swSrc file contains a sourcemap, we would invalidate that
|
|
1578
|
-
// mapping if we just replaced injectionPoint with the stringified manifest.
|
|
1579
|
-
// Instead, we need to update the swDest contents as well as the sourcemap
|
|
1580
|
-
// (assuming it's a real file, not a data: URL) at the same time.
|
|
1581
|
-
// See https://github.com/GoogleChrome/workbox/issues/2235
|
|
1582
|
-
// and https://github.com/GoogleChrome/workbox/issues/2648
|
|
1583
626
|
if (srcPath && destPath) {
|
|
1584
627
|
const originalMap = await fse.readJSON(srcPath, {
|
|
1585
628
|
encoding: "utf8"
|
|
@@ -1594,8 +637,6 @@ function translateURLToSourcemapPaths(url, swSrc, swDest) {
|
|
|
1594
637
|
filesToWrite[options.swDest] = source;
|
|
1595
638
|
filesToWrite[destPath] = map;
|
|
1596
639
|
} else {
|
|
1597
|
-
// If there's no sourcemap associated with swSrc, a simple string
|
|
1598
|
-
// replacement will suffice.
|
|
1599
640
|
filesToWrite[options.swDest] = swFileContents.replace(globalRegexp, manifestString);
|
|
1600
641
|
}
|
|
1601
642
|
for (const [file, contents] of Object.entries(filesToWrite)){
|
|
@@ -1610,9 +651,8 @@ function translateURLToSourcemapPaths(url, swSrc, swDest) {
|
|
|
1610
651
|
count,
|
|
1611
652
|
size,
|
|
1612
653
|
warnings,
|
|
1613
|
-
// Use upath.resolve() to make all the paths absolute.
|
|
1614
654
|
filePaths: Object.keys(filesToWrite).map((f)=>upath.resolve(f))
|
|
1615
655
|
};
|
|
1616
|
-
}
|
|
656
|
+
};
|
|
1617
657
|
|
|
1618
658
|
export { errors, escapeRegExp, getFileManifestEntries, getManifest, getSourceMapURL, injectManifest, rebasePath, replaceAndUpdateSourceMap, transformManifest, translateURLToSourcemapPaths, validateInjectManifestOptions, validateViteInjectManifestOptions, validateWebpackInjectManifestOptions };
|