@serwist/build 8.4.3 → 9.0.0-preview.0
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 +60 -0
- package/dist/chunks/injectManifest.js +23 -0
- package/dist/chunks/serwist-config-error.js +57 -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 +53 -813
- package/dist/index.next.d.ts +3 -0
- package/dist/index.next.d.ts.map +1 -0
- package/dist/index.next.js +35 -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/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 +42 -28
- 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/base.ts +16 -0
- package/src/schema/getManifest.ts +14 -0
- package/src/schema/glob.ts +41 -0
- package/src/schema/injectManifest.ts +23 -0
- package/src/schema/manifestEntry.ts +9 -0
- package/src/schema/manifestTransform.ts +15 -0
- package/src/schema/next.ts +35 -0
- package/src/schema/swDest.ts +14 -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,9 @@ 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 Ajv from 'ajv';
|
|
9
|
+
import { v as validationErrorMap, S as SerwistConfigError } from './chunks/serwist-config-error.js';
|
|
11
10
|
import { SourceMapGenerator, SourceMapConsumer } from 'source-map';
|
|
11
|
+
import 'zod';
|
|
12
12
|
|
|
13
13
|
const errors = {
|
|
14
14
|
"unable-to-get-rootdir": "Unable to get the root directory of your web app.",
|
|
@@ -76,10 +76,6 @@ const errors = {
|
|
|
76
76
|
'templatedURLs'.`,
|
|
77
77
|
"invalid-runtime-caching": oneLine`The 'runtimeCaching' parameter must an an
|
|
78
78
|
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
79
|
"urlPattern-is-required": oneLine`The 'urlPattern' option is required when using
|
|
84
80
|
'runtimeCaching'.`,
|
|
85
81
|
"handler-is-required": oneLine`The 'handler' option is required when using
|
|
@@ -104,7 +100,7 @@ const errors = {
|
|
|
104
100
|
an array of functions.`
|
|
105
101
|
};
|
|
106
102
|
|
|
107
|
-
|
|
103
|
+
const getCompositeDetails = (compositeURL, dependencyDetails)=>{
|
|
108
104
|
let totalSize = 0;
|
|
109
105
|
let compositeHash = "";
|
|
110
106
|
for (const fileDetails of dependencyDetails){
|
|
@@ -119,7 +115,7 @@ function getCompositeDetails(compositeURL, dependencyDetails) {
|
|
|
119
115
|
hash: hashOfHashes,
|
|
120
116
|
size: totalSize
|
|
121
117
|
};
|
|
122
|
-
}
|
|
118
|
+
};
|
|
123
119
|
|
|
124
120
|
function getStringHash(input) {
|
|
125
121
|
const md5 = crypto.createHash("md5");
|
|
@@ -194,7 +190,7 @@ function getStringDetails(url, str) {
|
|
|
194
190
|
};
|
|
195
191
|
}
|
|
196
192
|
|
|
197
|
-
|
|
193
|
+
const additionalPrecacheEntriesTransform = (additionalPrecacheEntries)=>{
|
|
198
194
|
return (manifest)=>{
|
|
199
195
|
const warnings = [];
|
|
200
196
|
const stringEntries = new Set();
|
|
@@ -229,7 +225,7 @@ function additionalPrecacheEntriesTransform(additionalPrecacheEntries) {
|
|
|
229
225
|
warnings
|
|
230
226
|
};
|
|
231
227
|
};
|
|
232
|
-
}
|
|
228
|
+
};
|
|
233
229
|
|
|
234
230
|
const BYTE_UNITS = [
|
|
235
231
|
'B',
|
|
@@ -359,9 +355,9 @@ function maximumSizeTransform(maximumFileSizeToCacheInBytes) {
|
|
|
359
355
|
license that can be found in the LICENSE file or at
|
|
360
356
|
https://opensource.org/licenses/MIT.
|
|
361
357
|
*/ // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
|
|
362
|
-
|
|
358
|
+
const escapeRegExp = (str)=>{
|
|
363
359
|
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
364
|
-
}
|
|
360
|
+
};
|
|
365
361
|
|
|
366
362
|
function modifyURLPrefixTransform(modifyURLPrefix) {
|
|
367
363
|
if (!modifyURLPrefix || typeof modifyURLPrefix !== "object" || Array.isArray(modifyURLPrefix)) {
|
|
@@ -569,809 +565,53 @@ async function getFileManifestEntries({ additionalPrecacheEntries, dontCacheBust
|
|
|
569
565
|
return transformedManifest;
|
|
570
566
|
}
|
|
571
567
|
|
|
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
|
-
]
|
|
568
|
+
const validateGetManifestOptions = async (input)=>{
|
|
569
|
+
const result = await (await import('./chunks/getManifest.js')).getManifestOptions.spa(input, {
|
|
570
|
+
errorMap: validationErrorMap
|
|
571
|
+
});
|
|
572
|
+
if (!result.success) {
|
|
573
|
+
throw new SerwistConfigError({
|
|
574
|
+
moduleName: "@serwist/build",
|
|
575
|
+
message: JSON.stringify(result.error.format(), null, 2)
|
|
576
|
+
});
|
|
1113
577
|
}
|
|
578
|
+
return result.data;
|
|
1114
579
|
};
|
|
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"
|
|
580
|
+
const validateInjectManifestOptions = async (input)=>{
|
|
581
|
+
const result = await (await import('./chunks/injectManifest.js').then(function (n) { return n.a; })).injectManifestOptions.spa(input, {
|
|
582
|
+
errorMap: validationErrorMap
|
|
583
|
+
});
|
|
584
|
+
if (!result.success) {
|
|
585
|
+
throw new SerwistConfigError({
|
|
586
|
+
moduleName: "@serwist/build",
|
|
587
|
+
message: JSON.stringify(result.error.format(), null, 2)
|
|
588
|
+
});
|
|
1221
589
|
}
|
|
590
|
+
return result.data;
|
|
1222
591
|
};
|
|
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
|
-
]
|
|
592
|
+
const validateWebpackInjectManifestOptions = async (input)=>{
|
|
593
|
+
const result = await (await import('./chunks/webpack.js')).webpackInjectManifestOptions.spa(input, {
|
|
594
|
+
errorMap: validationErrorMap
|
|
595
|
+
});
|
|
596
|
+
if (!result.success) {
|
|
597
|
+
throw new SerwistConfigError({
|
|
598
|
+
moduleName: "@serwist/webpack-plugin",
|
|
599
|
+
message: JSON.stringify(result.error.format(), null, 2)
|
|
600
|
+
});
|
|
1292
601
|
}
|
|
602
|
+
return result.data;
|
|
1293
603
|
};
|
|
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
|
|
604
|
+
const validateViteInjectManifestOptions = async (input)=>{
|
|
605
|
+
const result = await (await import('./chunks/vite.js')).viteInjectManifestOptions.spa(input, {
|
|
606
|
+
errorMap: validationErrorMap
|
|
1346
607
|
});
|
|
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"]);
|
|
608
|
+
if (!result.success) {
|
|
609
|
+
throw new SerwistConfigError({
|
|
610
|
+
moduleName: "@serwist/vite",
|
|
611
|
+
message: JSON.stringify(result.error.format(), null, 2)
|
|
612
|
+
});
|
|
1354
613
|
}
|
|
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;
|
|
614
|
+
return result.data;
|
|
1375
615
|
};
|
|
1376
616
|
|
|
1377
617
|
/**
|
|
@@ -1389,10 +629,10 @@ const validateViteInjectManifestOptions = (input)=>{
|
|
|
1389
629
|
* maximumFileSizeToCacheInBytes: ...,
|
|
1390
630
|
* });
|
|
1391
631
|
* ```
|
|
1392
|
-
*/ async
|
|
1393
|
-
const options = validateGetManifestOptions(config);
|
|
632
|
+
*/ const getManifest = async (config)=>{
|
|
633
|
+
const options = await validateGetManifestOptions(config);
|
|
1394
634
|
return await getFileManifestEntries(options);
|
|
1395
|
-
}
|
|
635
|
+
};
|
|
1396
636
|
|
|
1397
637
|
/*
|
|
1398
638
|
Copyright 2022 Google LLC
|
|
@@ -1536,8 +776,8 @@ function translateURLToSourcemapPaths(url, swSrc, swDest) {
|
|
|
1536
776
|
* swSrc: '...',
|
|
1537
777
|
* });
|
|
1538
778
|
* ```
|
|
1539
|
-
*/ async
|
|
1540
|
-
const options = validateInjectManifestOptions(config);
|
|
779
|
+
*/ const injectManifest = async (config)=>{
|
|
780
|
+
const options = await validateInjectManifestOptions(config);
|
|
1541
781
|
// Make sure we leave swSrc and swDest out of the precache manifest.
|
|
1542
782
|
for (const file of [
|
|
1543
783
|
options.swSrc,
|
|
@@ -1613,6 +853,6 @@ function translateURLToSourcemapPaths(url, swSrc, swDest) {
|
|
|
1613
853
|
// Use upath.resolve() to make all the paths absolute.
|
|
1614
854
|
filePaths: Object.keys(filesToWrite).map((f)=>upath.resolve(f))
|
|
1615
855
|
};
|
|
1616
|
-
}
|
|
856
|
+
};
|
|
1617
857
|
|
|
1618
858
|
export { errors, escapeRegExp, getFileManifestEntries, getManifest, getSourceMapURL, injectManifest, rebasePath, replaceAndUpdateSourceMap, transformManifest, translateURLToSourcemapPaths, validateInjectManifestOptions, validateViteInjectManifestOptions, validateWebpackInjectManifestOptions };
|