@serwist/webpack-plugin 9.0.0-preview.12 → 9.0.0-preview.13
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/schema.js +32 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -4
- package/dist/index.schema.d.ts +3 -0
- package/dist/index.schema.d.ts.map +1 -0
- package/dist/index.schema.js +3 -0
- package/dist/inject-manifest.d.ts +3 -3
- package/dist/inject-manifest.d.ts.map +1 -1
- package/dist/lib/get-manifest-entries-from-compilation.d.ts +3 -2
- package/dist/lib/get-manifest-entries-from-compilation.d.ts.map +1 -1
- package/dist/lib/schema.d.ts +225 -0
- package/dist/lib/schema.d.ts.map +1 -0
- package/dist/lib/types.d.ts +54 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/validator.d.ts +3 -0
- package/dist/lib/validator.d.ts.map +1 -0
- package/package.json +17 -9
- package/src/index.schema.ts +3 -0
- package/src/index.ts +4 -1
- package/src/inject-manifest.ts +7 -14
- package/src/lib/get-manifest-entries-from-compilation.ts +4 -3
- package/src/lib/schema.ts +28 -0
- package/src/lib/types.ts +71 -0
- package/src/lib/validator.ts +10 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { basePartial, injectPartial as injectPartial$1, optionalSwDestPartial } from '@serwist/build/schema';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
const webpackPartial = z.object({
|
|
5
|
+
chunks: z.array(z.string()).optional(),
|
|
6
|
+
exclude: z.array(z.union([
|
|
7
|
+
z.string(),
|
|
8
|
+
z.instanceof(RegExp),
|
|
9
|
+
z.function(z.tuple([
|
|
10
|
+
z.any()
|
|
11
|
+
]), z.boolean())
|
|
12
|
+
])).default([
|
|
13
|
+
/\.map$/,
|
|
14
|
+
/^manifest.*\.js$/
|
|
15
|
+
]),
|
|
16
|
+
excludeChunks: z.array(z.string()).optional(),
|
|
17
|
+
include: z.array(z.union([
|
|
18
|
+
z.string(),
|
|
19
|
+
z.instanceof(RegExp),
|
|
20
|
+
z.function(z.tuple([
|
|
21
|
+
z.any()
|
|
22
|
+
]), z.boolean())
|
|
23
|
+
])).optional()
|
|
24
|
+
}).strict("Do not pass invalid properties to WebpackPartial!");
|
|
25
|
+
const injectPartial = z.object({
|
|
26
|
+
compileSrc: z.boolean().default(true),
|
|
27
|
+
swDest: z.string().optional(),
|
|
28
|
+
webpackCompilationPlugins: z.array(z.any()).optional()
|
|
29
|
+
}).strict("Do not pass invalid properties to WebpackInjectManifestPartial!");
|
|
30
|
+
const injectManifestOptions = basePartial.merge(webpackPartial).merge(injectPartial$1).merge(optionalSwDestPartial).merge(injectPartial).strict("Do not pass invalid properties to WebpackInjectManifestOptions!");
|
|
31
|
+
|
|
32
|
+
export { injectManifestOptions, injectPartial, webpackPartial };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { InjectManifest } from "./inject-manifest.js";
|
|
2
|
-
|
|
2
|
+
import type { InjectManifestOptions, InjectManifestOptionsComplete, WebpackPartial, WebpackResolved } from "./lib/types.js";
|
|
3
|
+
import { validateInjectManifestOptions } from "./lib/validator.js";
|
|
4
|
+
export { InjectManifest, validateInjectManifestOptions };
|
|
5
|
+
export type { InjectManifestOptions, InjectManifestOptionsComplete, WebpackPartial, WebpackResolved };
|
|
3
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC5H,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,6BAA6B,EAAE,CAAC;AACzD,YAAY,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
|
-
import { transformManifest, getSourceMapURL,
|
|
2
|
-
import stringify from 'fast-json-stable-stringify';
|
|
1
|
+
import { transformManifest, getSourceMapURL, stringify, escapeRegExp, replaceAndUpdateSourceMap } from '@serwist/build';
|
|
3
2
|
import prettyBytes from 'pretty-bytes';
|
|
4
3
|
import upath from 'upath';
|
|
4
|
+
import { validationErrorMap, SerwistConfigError } from '@serwist/build/schema';
|
|
5
5
|
import crypto from 'crypto';
|
|
6
6
|
import { r as relativeToOutputPath } from './chunks/relative-to-output-path.js';
|
|
7
7
|
|
|
8
|
+
const validateInjectManifestOptions = async (input)=>{
|
|
9
|
+
const result = await (await import('./chunks/schema.js')).injectManifestOptions.spa(input, {
|
|
10
|
+
errorMap: validationErrorMap
|
|
11
|
+
});
|
|
12
|
+
if (!result.success) {
|
|
13
|
+
throw new SerwistConfigError({
|
|
14
|
+
moduleName: "@serwist/webpack-plugin",
|
|
15
|
+
message: JSON.stringify(result.error.format(), null, 2)
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return result.data;
|
|
19
|
+
};
|
|
20
|
+
|
|
8
21
|
const getAssetHash = (asset)=>{
|
|
9
22
|
if (asset.info?.immutable) {
|
|
10
23
|
return null;
|
|
@@ -238,7 +251,7 @@ class InjectManifest {
|
|
|
238
251
|
compilation.emitAsset(this.config.swDest, new this.webpack.sources.RawSource(source));
|
|
239
252
|
}
|
|
240
253
|
async handleMake(compilation, parentCompiler) {
|
|
241
|
-
this.config = await
|
|
254
|
+
this.config = await validateInjectManifestOptions(this.config);
|
|
242
255
|
this.config.swDest = relativeToOutputPath(compilation, this.config.swDest);
|
|
243
256
|
_generatedAssetNames.add(this.config.swDest);
|
|
244
257
|
if (this.config.compileSrc) {
|
|
@@ -288,4 +301,4 @@ class InjectManifest {
|
|
|
288
301
|
}
|
|
289
302
|
}
|
|
290
303
|
|
|
291
|
-
export { InjectManifest };
|
|
304
|
+
export { InjectManifest, validateInjectManifestOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.schema.d.ts","sourceRoot":"","sources":["../src/index.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEvF,OAAO,EAAE,cAAc,EAAE,aAAa,IAAI,qBAAqB,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { WebpackInjectManifestOptions } from "@serwist/build";
|
|
2
1
|
import type { Compiler } from "webpack";
|
|
2
|
+
import type { InjectManifestOptions } from "./lib/types.js";
|
|
3
3
|
/**
|
|
4
4
|
* This class supports compiling a service worker file provided via `swSrc`,
|
|
5
5
|
* and injecting into that service worker a list of URLs and revision
|
|
@@ -23,13 +23,13 @@ import type { Compiler } from "webpack";
|
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
25
|
export declare class InjectManifest {
|
|
26
|
-
protected config:
|
|
26
|
+
protected config: InjectManifestOptions;
|
|
27
27
|
private alreadyCalled;
|
|
28
28
|
private webpack;
|
|
29
29
|
/**
|
|
30
30
|
* Creates an instance of InjectManifest.
|
|
31
31
|
*/
|
|
32
|
-
constructor(config:
|
|
32
|
+
constructor(config: InjectManifestOptions);
|
|
33
33
|
/**
|
|
34
34
|
* @param compiler default compiler object passed from webpack
|
|
35
35
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-manifest.d.ts","sourceRoot":"","sources":["../src/inject-manifest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"inject-manifest.d.ts","sourceRoot":"","sources":["../src/inject-manifest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAe,QAAQ,EAAoC,MAAM,SAAS,CAAC;AACvF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAW5D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,cAAc;IACzB,SAAS,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACxC,OAAO,CAAC,aAAa,CAAU;IAC/B,OAAO,CAAC,OAAO,CAAiB;IAEhC;;OAEG;gBACS,MAAM,EAAE,qBAAqB;IAMzC;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAa9B;;;;OAIG;YACW,kBAAkB;IAwChC;;;;OAIG;IACH,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IA6B/B;;;;;OAKG;YACW,uBAAuB;IAiCrC;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAKtB;;;;;OAKG;YACW,UAAU;IAiBxB;;;;OAIG;YACW,SAAS;CAmDxB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { ManifestEntry
|
|
1
|
+
import type { ManifestEntry } from "@serwist/build";
|
|
2
2
|
import type { Compilation } from "webpack";
|
|
3
|
-
|
|
3
|
+
import type { InjectManifestOptions } from "./types.js";
|
|
4
|
+
export declare const getManifestEntriesFromCompilation: (compilation: Compilation, config: InjectManifestOptions) => Promise<{
|
|
4
5
|
size: number;
|
|
5
6
|
sortedEntries: ManifestEntry[] | undefined;
|
|
6
7
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-manifest-entries-from-compilation.d.ts","sourceRoot":"","sources":["../../src/lib/get-manifest-entries-from-compilation.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAe,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"get-manifest-entries-from-compilation.d.ts","sourceRoot":"","sources":["../../src/lib/get-manifest-entries-from-compilation.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,KAAK,EAAgB,WAAW,EAAgB,MAAM,SAAS,CAAC;AAIvE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAoKxD,eAAO,MAAM,iCAAiC,gBAC/B,WAAW,UAChB,qBAAqB;UACZ,MAAM;mBAAiB,aAAa,EAAE,GAAG,SAAS;EAgCpE,CAAC"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const webpackPartial: z.ZodObject<{
|
|
3
|
+
chunks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
4
|
+
exclude: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>, z.ZodFunction<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>]>, "many">>;
|
|
5
|
+
excludeChunks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
6
|
+
include: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>, z.ZodFunction<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>]>, "many">>;
|
|
7
|
+
}, "strict", z.ZodTypeAny, {
|
|
8
|
+
exclude: (string | RegExp | ((args_0: any) => boolean))[];
|
|
9
|
+
chunks?: string[] | undefined;
|
|
10
|
+
excludeChunks?: string[] | undefined;
|
|
11
|
+
include?: (string | RegExp | ((args_0: any) => boolean))[] | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
chunks?: string[] | undefined;
|
|
14
|
+
exclude?: (string | RegExp | ((args_0: any) => boolean))[] | undefined;
|
|
15
|
+
excludeChunks?: string[] | undefined;
|
|
16
|
+
include?: (string | RegExp | ((args_0: any) => boolean))[] | undefined;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const injectPartial: z.ZodObject<{
|
|
19
|
+
compileSrc: z.ZodDefault<z.ZodBoolean>;
|
|
20
|
+
swDest: z.ZodOptional<z.ZodString>;
|
|
21
|
+
webpackCompilationPlugins: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
22
|
+
}, "strict", z.ZodTypeAny, {
|
|
23
|
+
compileSrc: boolean;
|
|
24
|
+
swDest?: string | undefined;
|
|
25
|
+
webpackCompilationPlugins?: any[] | undefined;
|
|
26
|
+
}, {
|
|
27
|
+
compileSrc?: boolean | undefined;
|
|
28
|
+
swDest?: string | undefined;
|
|
29
|
+
webpackCompilationPlugins?: any[] | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
export declare const injectManifestOptions: z.ZodObject<{
|
|
32
|
+
chunks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
33
|
+
exclude: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>, z.ZodFunction<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>]>, "many">>;
|
|
34
|
+
excludeChunks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
35
|
+
include: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>, z.ZodFunction<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>]>, "many">>;
|
|
36
|
+
additionalPrecacheEntries: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
37
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
38
|
+
revision: z.ZodNullable<z.ZodString>;
|
|
39
|
+
url: z.ZodString;
|
|
40
|
+
}, "strict", z.ZodTypeAny, {
|
|
41
|
+
revision: string | null;
|
|
42
|
+
url: string;
|
|
43
|
+
integrity?: string | undefined;
|
|
44
|
+
}, {
|
|
45
|
+
revision: string | null;
|
|
46
|
+
url: string;
|
|
47
|
+
integrity?: string | undefined;
|
|
48
|
+
}>]>, "many">>;
|
|
49
|
+
disablePrecacheManifest: z.ZodDefault<z.ZodBoolean>;
|
|
50
|
+
dontCacheBustURLsMatching: z.ZodOptional<z.ZodType<RegExp, z.ZodTypeDef, RegExp>>;
|
|
51
|
+
manifestTransforms: z.ZodOptional<z.ZodArray<z.ZodFunction<z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
52
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
53
|
+
revision: z.ZodNullable<z.ZodString>;
|
|
54
|
+
url: z.ZodString;
|
|
55
|
+
size: z.ZodNumber;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
revision: string | null;
|
|
58
|
+
url: string;
|
|
59
|
+
size: number;
|
|
60
|
+
integrity?: string | undefined;
|
|
61
|
+
}, {
|
|
62
|
+
revision: string | null;
|
|
63
|
+
url: string;
|
|
64
|
+
size: number;
|
|
65
|
+
integrity?: string | undefined;
|
|
66
|
+
}>, "many">, z.ZodOptional<z.ZodUnknown>], null>, z.ZodUnion<[z.ZodPromise<z.ZodObject<{
|
|
67
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
68
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
69
|
+
revision: z.ZodNullable<z.ZodString>;
|
|
70
|
+
url: z.ZodString;
|
|
71
|
+
size: z.ZodNumber;
|
|
72
|
+
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
revision: string | null;
|
|
74
|
+
url: string;
|
|
75
|
+
size: number;
|
|
76
|
+
integrity?: string | undefined;
|
|
77
|
+
}, {
|
|
78
|
+
revision: string | null;
|
|
79
|
+
url: string;
|
|
80
|
+
size: number;
|
|
81
|
+
integrity?: string | undefined;
|
|
82
|
+
}>, "many">;
|
|
83
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
84
|
+
}, "strict", z.ZodTypeAny, {
|
|
85
|
+
manifest: {
|
|
86
|
+
revision: string | null;
|
|
87
|
+
url: string;
|
|
88
|
+
size: number;
|
|
89
|
+
integrity?: string | undefined;
|
|
90
|
+
}[];
|
|
91
|
+
warnings?: string[] | undefined;
|
|
92
|
+
}, {
|
|
93
|
+
manifest: {
|
|
94
|
+
revision: string | null;
|
|
95
|
+
url: string;
|
|
96
|
+
size: number;
|
|
97
|
+
integrity?: string | undefined;
|
|
98
|
+
}[];
|
|
99
|
+
warnings?: string[] | undefined;
|
|
100
|
+
}>>, z.ZodObject<{
|
|
101
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
102
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
103
|
+
revision: z.ZodNullable<z.ZodString>;
|
|
104
|
+
url: z.ZodString;
|
|
105
|
+
size: z.ZodNumber;
|
|
106
|
+
}, "strip", z.ZodTypeAny, {
|
|
107
|
+
revision: string | null;
|
|
108
|
+
url: string;
|
|
109
|
+
size: number;
|
|
110
|
+
integrity?: string | undefined;
|
|
111
|
+
}, {
|
|
112
|
+
revision: string | null;
|
|
113
|
+
url: string;
|
|
114
|
+
size: number;
|
|
115
|
+
integrity?: string | undefined;
|
|
116
|
+
}>, "many">;
|
|
117
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
118
|
+
}, "strict", z.ZodTypeAny, {
|
|
119
|
+
manifest: {
|
|
120
|
+
revision: string | null;
|
|
121
|
+
url: string;
|
|
122
|
+
size: number;
|
|
123
|
+
integrity?: string | undefined;
|
|
124
|
+
}[];
|
|
125
|
+
warnings?: string[] | undefined;
|
|
126
|
+
}, {
|
|
127
|
+
manifest: {
|
|
128
|
+
revision: string | null;
|
|
129
|
+
url: string;
|
|
130
|
+
size: number;
|
|
131
|
+
integrity?: string | undefined;
|
|
132
|
+
}[];
|
|
133
|
+
warnings?: string[] | undefined;
|
|
134
|
+
}>]>>, "many">>;
|
|
135
|
+
maximumFileSizeToCacheInBytes: z.ZodDefault<z.ZodNumber>;
|
|
136
|
+
modifyURLPrefix: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
137
|
+
injectionPoint: z.ZodDefault<z.ZodString>;
|
|
138
|
+
swSrc: z.ZodString;
|
|
139
|
+
compileSrc: z.ZodDefault<z.ZodBoolean>;
|
|
140
|
+
swDest: z.ZodOptional<z.ZodString>;
|
|
141
|
+
webpackCompilationPlugins: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
142
|
+
}, "strict", z.ZodTypeAny, {
|
|
143
|
+
exclude: (string | RegExp | ((args_0: any) => boolean))[];
|
|
144
|
+
compileSrc: boolean;
|
|
145
|
+
disablePrecacheManifest: boolean;
|
|
146
|
+
maximumFileSizeToCacheInBytes: number;
|
|
147
|
+
injectionPoint: string;
|
|
148
|
+
swSrc: string;
|
|
149
|
+
chunks?: string[] | undefined;
|
|
150
|
+
excludeChunks?: string[] | undefined;
|
|
151
|
+
include?: (string | RegExp | ((args_0: any) => boolean))[] | undefined;
|
|
152
|
+
additionalPrecacheEntries?: (string | {
|
|
153
|
+
revision: string | null;
|
|
154
|
+
url: string;
|
|
155
|
+
integrity?: string | undefined;
|
|
156
|
+
})[] | undefined;
|
|
157
|
+
dontCacheBustURLsMatching?: RegExp | undefined;
|
|
158
|
+
manifestTransforms?: ((args_0: {
|
|
159
|
+
revision: string | null;
|
|
160
|
+
url: string;
|
|
161
|
+
size: number;
|
|
162
|
+
integrity?: string | undefined;
|
|
163
|
+
}[], args_1: unknown) => {
|
|
164
|
+
manifest: {
|
|
165
|
+
revision: string | null;
|
|
166
|
+
url: string;
|
|
167
|
+
size: number;
|
|
168
|
+
integrity?: string | undefined;
|
|
169
|
+
}[];
|
|
170
|
+
warnings?: string[] | undefined;
|
|
171
|
+
} | Promise<{
|
|
172
|
+
manifest: {
|
|
173
|
+
revision: string | null;
|
|
174
|
+
url: string;
|
|
175
|
+
size: number;
|
|
176
|
+
integrity?: string | undefined;
|
|
177
|
+
}[];
|
|
178
|
+
warnings?: string[] | undefined;
|
|
179
|
+
}>)[] | undefined;
|
|
180
|
+
modifyURLPrefix?: Record<string, string> | undefined;
|
|
181
|
+
swDest?: string | undefined;
|
|
182
|
+
webpackCompilationPlugins?: any[] | undefined;
|
|
183
|
+
}, {
|
|
184
|
+
swSrc: string;
|
|
185
|
+
chunks?: string[] | undefined;
|
|
186
|
+
exclude?: (string | RegExp | ((args_0: any) => boolean))[] | undefined;
|
|
187
|
+
excludeChunks?: string[] | undefined;
|
|
188
|
+
include?: (string | RegExp | ((args_0: any) => boolean))[] | undefined;
|
|
189
|
+
additionalPrecacheEntries?: (string | {
|
|
190
|
+
revision: string | null;
|
|
191
|
+
url: string;
|
|
192
|
+
integrity?: string | undefined;
|
|
193
|
+
})[] | undefined;
|
|
194
|
+
disablePrecacheManifest?: boolean | undefined;
|
|
195
|
+
dontCacheBustURLsMatching?: RegExp | undefined;
|
|
196
|
+
manifestTransforms?: ((args_0: {
|
|
197
|
+
revision: string | null;
|
|
198
|
+
url: string;
|
|
199
|
+
size: number;
|
|
200
|
+
integrity?: string | undefined;
|
|
201
|
+
}[], args_1: unknown) => {
|
|
202
|
+
manifest: {
|
|
203
|
+
revision: string | null;
|
|
204
|
+
url: string;
|
|
205
|
+
size: number;
|
|
206
|
+
integrity?: string | undefined;
|
|
207
|
+
}[];
|
|
208
|
+
warnings?: string[] | undefined;
|
|
209
|
+
} | Promise<{
|
|
210
|
+
manifest: {
|
|
211
|
+
revision: string | null;
|
|
212
|
+
url: string;
|
|
213
|
+
size: number;
|
|
214
|
+
integrity?: string | undefined;
|
|
215
|
+
}[];
|
|
216
|
+
warnings?: string[] | undefined;
|
|
217
|
+
}>)[] | undefined;
|
|
218
|
+
maximumFileSizeToCacheInBytes?: number | undefined;
|
|
219
|
+
modifyURLPrefix?: Record<string, string> | undefined;
|
|
220
|
+
injectionPoint?: string | undefined;
|
|
221
|
+
compileSrc?: boolean | undefined;
|
|
222
|
+
swDest?: string | undefined;
|
|
223
|
+
webpackCompilationPlugins?: any[] | undefined;
|
|
224
|
+
}>;
|
|
225
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/lib/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;EASmC,CAAC;AAE/D,eAAO,MAAM,aAAa;;;;;;;;;;;;EAMkD,CAAC;AAE7E,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK0C,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { BasePartial, BaseResolved, InjectPartial as BaseInjectPartial, InjectResolved as BaseInjectResolved, OptionalSwDestPartial, OptionalSwDestResolved } from "@serwist/build";
|
|
2
|
+
import type { Require } from "@serwist/utils";
|
|
3
|
+
export interface WebpackPartial {
|
|
4
|
+
/**
|
|
5
|
+
* One or more chunk names whose corresponding output files should be included
|
|
6
|
+
* in the precache manifest.
|
|
7
|
+
*/
|
|
8
|
+
chunks?: string[];
|
|
9
|
+
/**
|
|
10
|
+
* One or more specifiers used to exclude assets from the precache manifest.
|
|
11
|
+
* This is interpreted following
|
|
12
|
+
* [the same rules](https://webpack.js.org/configuration/module/#condition)
|
|
13
|
+
* as webpack's standard `exclude` option.
|
|
14
|
+
* @default
|
|
15
|
+
* ```
|
|
16
|
+
* [/\.map$/, /^manifest.*\.js$/]
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
exclude?: (string | RegExp | ((arg0: any) => boolean))[];
|
|
20
|
+
/**
|
|
21
|
+
* One or more chunk names whose corresponding output files should be excluded
|
|
22
|
+
* from the precache manifest.
|
|
23
|
+
*/
|
|
24
|
+
excludeChunks?: string[];
|
|
25
|
+
/**
|
|
26
|
+
* One or more specifiers used to include assets in the precache manifest.
|
|
27
|
+
* This is interpreted following
|
|
28
|
+
* [the same rules](https://webpack.js.org/configuration/module/#condition)
|
|
29
|
+
* as webpack's standard `include` option.
|
|
30
|
+
*/
|
|
31
|
+
include?: (string | RegExp | ((arg0: any) => boolean))[];
|
|
32
|
+
}
|
|
33
|
+
export type WebpackResolved = Require<WebpackPartial, "exclude">;
|
|
34
|
+
export interface InjectPartial {
|
|
35
|
+
/**
|
|
36
|
+
* When `true` (the default), the `swSrc` file will be compiled by webpack.
|
|
37
|
+
* When `false`, compilation will not occur (and `webpackCompilationPlugins`
|
|
38
|
+
* can't be used.) Set to `false` if you want to inject the manifest into,
|
|
39
|
+
* e.g., a JSON file.
|
|
40
|
+
* @default true
|
|
41
|
+
*/
|
|
42
|
+
compileSrc?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Optional webpack plugins that will be used when compiling the `swSrc`
|
|
45
|
+
* input file. Only valid if `compileSrc` is `true`.
|
|
46
|
+
*/
|
|
47
|
+
webpackCompilationPlugins?: any[];
|
|
48
|
+
}
|
|
49
|
+
export type InjectResolved = Require<InjectPartial, "compileSrc">;
|
|
50
|
+
export interface InjectManifestOptions extends BasePartial, WebpackPartial, BaseInjectPartial, OptionalSwDestPartial, InjectPartial {
|
|
51
|
+
}
|
|
52
|
+
export interface InjectManifestOptionsComplete extends BaseResolved, WebpackResolved, BaseInjectResolved, OptionalSwDestResolved, InjectResolved {
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,aAAa,IAAI,iBAAiB,EAClC,cAAc,IAAI,kBAAkB,EACpC,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAKlB;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC;IACzD;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC;CAC1D;AAED,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;AAEjE,MAAM,WAAW,aAAa;IAC5B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAIrB;;;OAGG;IACH,yBAAyB,CAAC,EAAE,GAAG,EAAE,CAAC;CACnC;AAED,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;AAElE,MAAM,WAAW,qBAAsB,SAAQ,WAAW,EAAE,cAAc,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,aAAa;CAAG;AAEtI,MAAM,WAAW,6BAA8B,SAAQ,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,cAAc;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/lib/validator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAEhE,eAAO,MAAM,6BAA6B,UAAiB,OAAO,KAAG,QAAQ,6BAA6B,CAMzG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/webpack-plugin",
|
|
3
|
-
"version": "9.0.0-preview.
|
|
3
|
+
"version": "9.0.0-preview.13",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "A plugin for your
|
|
5
|
+
"description": "A plugin for your webpack build process, helping you generate a manifest of local files that should be precached.",
|
|
6
6
|
"files": [
|
|
7
7
|
"src",
|
|
8
8
|
"dist"
|
|
@@ -31,6 +31,9 @@
|
|
|
31
31
|
"*": {
|
|
32
32
|
"internal": [
|
|
33
33
|
"./dist/index.internal.d.ts"
|
|
34
|
+
],
|
|
35
|
+
"schema": [
|
|
36
|
+
"./dist/index.schema.d.ts"
|
|
34
37
|
]
|
|
35
38
|
}
|
|
36
39
|
},
|
|
@@ -43,21 +46,26 @@
|
|
|
43
46
|
"types": "./dist/index.internal.d.ts",
|
|
44
47
|
"default": "./dist/index.internal.js"
|
|
45
48
|
},
|
|
49
|
+
"./schema": {
|
|
50
|
+
"types": "./dist/index.schema.d.ts",
|
|
51
|
+
"default": "./dist/index.schema.js"
|
|
52
|
+
},
|
|
46
53
|
"./package.json": "./package.json"
|
|
47
54
|
},
|
|
48
55
|
"dependencies": {
|
|
49
|
-
"fast-json-stable-stringify": "2.1.0",
|
|
50
56
|
"pretty-bytes": "6.1.1",
|
|
51
57
|
"upath": "2.0.1",
|
|
52
|
-
"
|
|
58
|
+
"zod": "3.22.4",
|
|
59
|
+
"@serwist/build": "9.0.0-preview.13"
|
|
53
60
|
},
|
|
54
61
|
"devDependencies": {
|
|
55
|
-
"@types/node": "20.11.
|
|
62
|
+
"@types/node": "20.11.24",
|
|
56
63
|
"@types/webpack": "5.28.5",
|
|
57
|
-
"rollup": "4.
|
|
58
|
-
"typescript": "5.
|
|
59
|
-
"webpack": "5.90.
|
|
60
|
-
"@serwist/
|
|
64
|
+
"rollup": "4.12.0",
|
|
65
|
+
"typescript": "5.5.0-dev.20240304",
|
|
66
|
+
"webpack": "5.90.3",
|
|
67
|
+
"@serwist/utils": "9.0.0-preview.13",
|
|
68
|
+
"@serwist/constants": "9.0.0-preview.13"
|
|
61
69
|
},
|
|
62
70
|
"peerDependencies": {
|
|
63
71
|
"typescript": ">=5.0.0",
|
package/src/index.ts
CHANGED
|
@@ -7,5 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { InjectManifest } from "./inject-manifest.js";
|
|
10
|
+
import type { InjectManifestOptions, InjectManifestOptionsComplete, WebpackPartial, WebpackResolved } from "./lib/types.js";
|
|
11
|
+
import { validateInjectManifestOptions } from "./lib/validator.js";
|
|
10
12
|
|
|
11
|
-
export { InjectManifest };
|
|
13
|
+
export { InjectManifest, validateInjectManifestOptions };
|
|
14
|
+
export type { InjectManifestOptions, InjectManifestOptionsComplete, WebpackPartial, WebpackResolved };
|
package/src/inject-manifest.ts
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Copyright 2018 Google LLC
|
|
3
|
-
|
|
4
|
-
Use of this source code is governed by an MIT-style
|
|
5
|
-
license that can be found in the LICENSE file or at
|
|
6
|
-
https://opensource.org/licenses/MIT.
|
|
7
|
-
*/
|
|
8
|
-
import type { WebpackInjectManifestOptions } from "@serwist/build";
|
|
9
|
-
import { escapeRegExp, replaceAndUpdateSourceMap, validateWebpackInjectManifestOptions } from "@serwist/build";
|
|
10
|
-
import stringify from "fast-json-stable-stringify";
|
|
1
|
+
import { escapeRegExp, replaceAndUpdateSourceMap, stringify } from "@serwist/build";
|
|
11
2
|
import prettyBytes from "pretty-bytes";
|
|
12
3
|
import upath from "upath";
|
|
13
4
|
import type { Compilation, Compiler, WebpackError, default as Webpack } from "webpack";
|
|
5
|
+
import type { InjectManifestOptions } from "./lib/types.js";
|
|
6
|
+
import { validateInjectManifestOptions } from "./lib/validator.js";
|
|
14
7
|
|
|
15
8
|
import { getManifestEntriesFromCompilation } from "./lib/get-manifest-entries-from-compilation.js";
|
|
16
9
|
import { getSourcemapAssetName } from "./lib/get-sourcemap-asset-name.js";
|
|
@@ -43,14 +36,14 @@ const _generatedAssetNames = new Set<string>();
|
|
|
43
36
|
* ```
|
|
44
37
|
*/
|
|
45
38
|
export class InjectManifest {
|
|
46
|
-
protected config:
|
|
39
|
+
protected config: InjectManifestOptions;
|
|
47
40
|
private alreadyCalled: boolean;
|
|
48
41
|
private webpack: typeof Webpack;
|
|
49
42
|
|
|
50
43
|
/**
|
|
51
44
|
* Creates an instance of InjectManifest.
|
|
52
45
|
*/
|
|
53
|
-
constructor(config:
|
|
46
|
+
constructor(config: InjectManifestOptions) {
|
|
54
47
|
this.config = config;
|
|
55
48
|
this.alreadyCalled = false;
|
|
56
49
|
this.webpack = null!;
|
|
@@ -79,7 +72,7 @@ export class InjectManifest {
|
|
|
79
72
|
*
|
|
80
73
|
* @private
|
|
81
74
|
*/
|
|
82
|
-
private async getManifestEntries(compilation: Compilation, config:
|
|
75
|
+
private async getManifestEntries(compilation: Compilation, config: InjectManifestOptions) {
|
|
83
76
|
if (config.disablePrecacheManifest) {
|
|
84
77
|
return {
|
|
85
78
|
size: 0,
|
|
@@ -210,7 +203,7 @@ export class InjectManifest {
|
|
|
210
203
|
* @private
|
|
211
204
|
*/
|
|
212
205
|
private async handleMake(compilation: Compilation, parentCompiler: Compiler): Promise<void> {
|
|
213
|
-
this.config = await
|
|
206
|
+
this.config = await validateInjectManifestOptions(this.config);
|
|
214
207
|
this.config.swDest = relativeToOutputPath(compilation, this.config.swDest!);
|
|
215
208
|
_generatedAssetNames.add(this.config.swDest);
|
|
216
209
|
|
|
@@ -6,12 +6,13 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { FileDetails, ManifestEntry
|
|
9
|
+
import type { FileDetails, ManifestEntry } from "@serwist/build";
|
|
10
10
|
import { transformManifest } from "@serwist/build";
|
|
11
11
|
import type { Asset, Chunk, Compilation, WebpackError } from "webpack";
|
|
12
12
|
|
|
13
13
|
import { getAssetHash } from "./get-asset-hash.js";
|
|
14
14
|
import { resolveWebpackURL } from "./resolve-webpack-url.js";
|
|
15
|
+
import type { InjectManifestOptions } from "./types.js";
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* For a given asset, checks whether at least one of the conditions matches.
|
|
@@ -104,7 +105,7 @@ const getNamesOfAssetsInChunk = (chunk: Chunk): string[] => {
|
|
|
104
105
|
* based on the criteria provided.
|
|
105
106
|
* @private
|
|
106
107
|
*/
|
|
107
|
-
const filterAssets = (compilation: Compilation, config:
|
|
108
|
+
const filterAssets = (compilation: Compilation, config: InjectManifestOptions): Set<Asset> => {
|
|
108
109
|
const filteredAssets = new Set<Asset>();
|
|
109
110
|
const assets = compilation.getAssets();
|
|
110
111
|
|
|
@@ -177,7 +178,7 @@ const filterAssets = (compilation: Compilation, config: WebpackInjectManifestOpt
|
|
|
177
178
|
|
|
178
179
|
export const getManifestEntriesFromCompilation = async (
|
|
179
180
|
compilation: Compilation,
|
|
180
|
-
config:
|
|
181
|
+
config: InjectManifestOptions,
|
|
181
182
|
): Promise<{ size: number; sortedEntries: ManifestEntry[] | undefined }> => {
|
|
182
183
|
const filteredAssets = filterAssets(compilation, config);
|
|
183
184
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { basePartial, injectPartial as baseInjectPartial, optionalSwDestPartial } from "@serwist/build/schema";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
export const webpackPartial = z
|
|
5
|
+
.object({
|
|
6
|
+
chunks: z.array(z.string()).optional(),
|
|
7
|
+
exclude: z
|
|
8
|
+
.array(z.union([z.string(), z.instanceof(RegExp), z.function(z.tuple([z.any()]), z.boolean())]))
|
|
9
|
+
.default([/\.map$/, /^manifest.*\.js$/]),
|
|
10
|
+
excludeChunks: z.array(z.string()).optional(),
|
|
11
|
+
include: z.array(z.union([z.string(), z.instanceof(RegExp), z.function(z.tuple([z.any()]), z.boolean())])).optional(),
|
|
12
|
+
})
|
|
13
|
+
.strict("Do not pass invalid properties to WebpackPartial!");
|
|
14
|
+
|
|
15
|
+
export const injectPartial = z
|
|
16
|
+
.object({
|
|
17
|
+
compileSrc: z.boolean().default(true),
|
|
18
|
+
swDest: z.string().optional(),
|
|
19
|
+
webpackCompilationPlugins: z.array(z.any()).optional(),
|
|
20
|
+
})
|
|
21
|
+
.strict("Do not pass invalid properties to WebpackInjectManifestPartial!");
|
|
22
|
+
|
|
23
|
+
export const injectManifestOptions = basePartial
|
|
24
|
+
.merge(webpackPartial)
|
|
25
|
+
.merge(baseInjectPartial)
|
|
26
|
+
.merge(optionalSwDestPartial)
|
|
27
|
+
.merge(injectPartial)
|
|
28
|
+
.strict("Do not pass invalid properties to WebpackInjectManifestOptions!");
|
package/src/lib/types.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
BasePartial,
|
|
3
|
+
BaseResolved,
|
|
4
|
+
InjectPartial as BaseInjectPartial,
|
|
5
|
+
InjectResolved as BaseInjectResolved,
|
|
6
|
+
OptionalSwDestPartial,
|
|
7
|
+
OptionalSwDestResolved,
|
|
8
|
+
} from "@serwist/build";
|
|
9
|
+
import type { Require } from "@serwist/utils";
|
|
10
|
+
|
|
11
|
+
export interface WebpackPartial {
|
|
12
|
+
/**
|
|
13
|
+
* One or more chunk names whose corresponding output files should be included
|
|
14
|
+
* in the precache manifest.
|
|
15
|
+
*/
|
|
16
|
+
chunks?: string[];
|
|
17
|
+
// We can't use the @default annotation here to assign the value via AJV, as
|
|
18
|
+
// an (RegExp)[] can't be serialized into JSON.
|
|
19
|
+
// The default value of [/\.map$/, /^manifest.*\.js$/] will be assigned by
|
|
20
|
+
// the validation function, and we need to reflect that in the docs.
|
|
21
|
+
/**
|
|
22
|
+
* One or more specifiers used to exclude assets from the precache manifest.
|
|
23
|
+
* This is interpreted following
|
|
24
|
+
* [the same rules](https://webpack.js.org/configuration/module/#condition)
|
|
25
|
+
* as webpack's standard `exclude` option.
|
|
26
|
+
* @default
|
|
27
|
+
* ```
|
|
28
|
+
* [/\.map$/, /^manifest.*\.js$/]
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
exclude?: (string | RegExp | ((arg0: any) => boolean))[];
|
|
32
|
+
/**
|
|
33
|
+
* One or more chunk names whose corresponding output files should be excluded
|
|
34
|
+
* from the precache manifest.
|
|
35
|
+
*/
|
|
36
|
+
excludeChunks?: string[];
|
|
37
|
+
/**
|
|
38
|
+
* One or more specifiers used to include assets in the precache manifest.
|
|
39
|
+
* This is interpreted following
|
|
40
|
+
* [the same rules](https://webpack.js.org/configuration/module/#condition)
|
|
41
|
+
* as webpack's standard `include` option.
|
|
42
|
+
*/
|
|
43
|
+
include?: (string | RegExp | ((arg0: any) => boolean))[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type WebpackResolved = Require<WebpackPartial, "exclude">;
|
|
47
|
+
|
|
48
|
+
export interface InjectPartial {
|
|
49
|
+
/**
|
|
50
|
+
* When `true` (the default), the `swSrc` file will be compiled by webpack.
|
|
51
|
+
* When `false`, compilation will not occur (and `webpackCompilationPlugins`
|
|
52
|
+
* can't be used.) Set to `false` if you want to inject the manifest into,
|
|
53
|
+
* e.g., a JSON file.
|
|
54
|
+
* @default true
|
|
55
|
+
*/
|
|
56
|
+
compileSrc?: boolean;
|
|
57
|
+
// This can only be set if `compileSrc` is true, but that restriction can't be
|
|
58
|
+
// represented in TypeScript. It's enforced via custom runtime validation
|
|
59
|
+
// logic and needs to be documented.
|
|
60
|
+
/**
|
|
61
|
+
* Optional webpack plugins that will be used when compiling the `swSrc`
|
|
62
|
+
* input file. Only valid if `compileSrc` is `true`.
|
|
63
|
+
*/
|
|
64
|
+
webpackCompilationPlugins?: any[];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type InjectResolved = Require<InjectPartial, "compileSrc">;
|
|
68
|
+
|
|
69
|
+
export interface InjectManifestOptions extends BasePartial, WebpackPartial, BaseInjectPartial, OptionalSwDestPartial, InjectPartial {}
|
|
70
|
+
|
|
71
|
+
export interface InjectManifestOptionsComplete extends BaseResolved, WebpackResolved, BaseInjectResolved, OptionalSwDestResolved, InjectResolved {}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SerwistConfigError, validationErrorMap } from "@serwist/build/schema";
|
|
2
|
+
import type { InjectManifestOptionsComplete } from "./types.js";
|
|
3
|
+
|
|
4
|
+
export const validateInjectManifestOptions = async (input: unknown): Promise<InjectManifestOptionsComplete> => {
|
|
5
|
+
const result = await (await import("./schema.js")).injectManifestOptions.spa(input, { errorMap: validationErrorMap });
|
|
6
|
+
if (!result.success) {
|
|
7
|
+
throw new SerwistConfigError({ moduleName: "@serwist/webpack-plugin", message: JSON.stringify(result.error.format(), null, 2) });
|
|
8
|
+
}
|
|
9
|
+
return result.data;
|
|
10
|
+
};
|