@serwist/webpack-plugin 10.0.0-preview.7 → 10.0.0-preview.9
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/relative-to-output-path.js +1 -1
- package/dist/chunks/schema.js +25 -20
- package/dist/index.internal.js +1 -1
- package/dist/index.js +7 -5
- package/dist/lib/get-manifest-entries-from-compilation.d.ts.map +1 -1
- package/dist/lib/relative-to-output-path.d.ts.map +1 -1
- package/dist/lib/schema.d.ts +60 -203
- package/dist/lib/schema.d.ts.map +1 -1
- package/dist/lib/types.d.ts +1 -1
- package/dist/lib/types.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/lib/get-manifest-entries-from-compilation.ts +8 -10
- package/src/lib/relative-to-output-path.ts +2 -1
- package/src/lib/schema.ts +26 -24
- package/src/lib/types.ts +1 -1
- package/src/lib/validator.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { toUnix } from '@serwist/utils';
|
|
2
1
|
import path from 'node:path';
|
|
2
|
+
import { toUnix } from '@serwist/utils';
|
|
3
3
|
|
|
4
4
|
const performChildCompilation = async (compiler, compilation, name, src, dest, plugins)=>{
|
|
5
5
|
const childCompiler = compilation.createChildCompiler(name, {
|
package/dist/chunks/schema.js
CHANGED
|
@@ -1,32 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { fn, optionalSwDestPartial, injectPartial as injectPartial$1, basePartial } from '@serwist/build/schema';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const webpackConditionCallback = fn({
|
|
5
|
+
input: [
|
|
6
|
+
z.any()
|
|
7
|
+
],
|
|
8
|
+
output: z.boolean()
|
|
9
|
+
});
|
|
10
|
+
const webpackCondition = z.union([
|
|
11
|
+
z.string(),
|
|
12
|
+
z.instanceof(RegExp),
|
|
13
|
+
webpackConditionCallback
|
|
14
|
+
]);
|
|
15
|
+
const webpackPartial = z.strictObject({
|
|
5
16
|
chunks: z.array(z.string()).optional(),
|
|
6
|
-
exclude: z.array(
|
|
7
|
-
z.string(),
|
|
8
|
-
z.instanceof(RegExp),
|
|
9
|
-
z.function(z.tuple([
|
|
10
|
-
z.any()
|
|
11
|
-
]), z.boolean())
|
|
12
|
-
])).default([
|
|
17
|
+
exclude: z.array(webpackCondition).default([
|
|
13
18
|
/\.map$/,
|
|
14
19
|
/^manifest.*\.js$/
|
|
15
20
|
]),
|
|
16
21
|
excludeChunks: z.array(z.string()).optional(),
|
|
17
|
-
include: z.array(
|
|
18
|
-
|
|
19
|
-
|
|
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({
|
|
22
|
+
include: z.array(webpackCondition).optional()
|
|
23
|
+
});
|
|
24
|
+
const injectPartial = z.strictObject({
|
|
26
25
|
compileSrc: z.boolean().default(true),
|
|
27
26
|
swDest: z.string().optional(),
|
|
28
27
|
webpackCompilationPlugins: z.array(z.any()).optional()
|
|
29
|
-
})
|
|
30
|
-
const injectManifestOptions =
|
|
28
|
+
});
|
|
29
|
+
const injectManifestOptions = z.strictObject({
|
|
30
|
+
...basePartial.shape,
|
|
31
|
+
...webpackPartial.shape,
|
|
32
|
+
...injectPartial$1.shape,
|
|
33
|
+
...optionalSwDestPartial.shape,
|
|
34
|
+
...injectPartial.shape
|
|
35
|
+
});
|
|
31
36
|
|
|
32
37
|
export { injectManifestOptions, injectPartial, webpackPartial };
|
package/dist/index.internal.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -24,14 +24,16 @@ const resolveWebpackURL = (publicPath, ...paths)=>{
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
const checkConditions = (asset, compilation, conditions = [])=>{
|
|
27
|
+
const matchPart = compilation.compiler.webpack.ModuleFilenameHelpers.matchPart;
|
|
27
28
|
for (const condition of conditions){
|
|
28
29
|
if (typeof condition === "function") {
|
|
29
|
-
|
|
30
|
+
if (condition({
|
|
30
31
|
asset,
|
|
31
32
|
compilation
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
})) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
} else if (matchPart(asset.name, condition)) {
|
|
35
37
|
return true;
|
|
36
38
|
}
|
|
37
39
|
}
|
|
@@ -150,7 +152,7 @@ const getSourcemapAssetName = (compilation, swContents, swDest)=>{
|
|
|
150
152
|
|
|
151
153
|
const validateInjectManifestOptions = async (input)=>{
|
|
152
154
|
const result = await (await import('./chunks/schema.js')).injectManifestOptions.spa(input, {
|
|
153
|
-
|
|
155
|
+
error: validationErrorMap
|
|
154
156
|
});
|
|
155
157
|
if (!result.success) {
|
|
156
158
|
throw new SerwistConfigError({
|
|
@@ -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,MAAM,gBAAgB,CAAC;
|
|
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;AAGpD,OAAO,KAAK,EAAgB,WAAW,EAAgB,MAAM,SAAS,CAAC;AAIvE,OAAO,KAAK,EAAyB,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAiKvF,eAAO,MAAM,iCAAiC,GAC5C,aAAa,WAAW,EACxB,QAAQ,6BAA6B,KACpC,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,aAAa,EAAE,GAAG,SAAS,CAAA;CAAE,CAiCtE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relative-to-output-path.d.ts","sourceRoot":"","sources":["../../src/lib/relative-to-output-path.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"relative-to-output-path.d.ts","sourceRoot":"","sources":["../../src/lib/relative-to-output-path.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,GAAI,aAAa,WAAW,EAAE,cAAc,MAAM,KAAG,MAQrF,CAAC"}
|
package/dist/lib/schema.d.ts
CHANGED
|
@@ -1,229 +1,86 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const webpackPartial: z.ZodObject<{
|
|
3
|
-
chunks: z.ZodOptional<z.ZodArray<z.ZodString
|
|
4
|
-
exclude: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.
|
|
5
|
-
excludeChunks: z.ZodOptional<z.ZodArray<z.ZodString
|
|
6
|
-
include: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.
|
|
7
|
-
},
|
|
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
|
-
exclude?: (string | RegExp | ((args_0: any) => boolean))[] | undefined;
|
|
14
|
-
chunks?: string[] | undefined;
|
|
15
|
-
excludeChunks?: string[] | undefined;
|
|
16
|
-
include?: (string | RegExp | ((args_0: any) => boolean))[] | undefined;
|
|
17
|
-
}>;
|
|
3
|
+
chunks: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
4
|
+
exclude: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<RegExp, RegExp>, z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>>, z.ZodTransform<(args_0: any) => boolean, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>>>]>>>;
|
|
5
|
+
excludeChunks: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
6
|
+
include: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<RegExp, RegExp>, z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>>, z.ZodTransform<(args_0: any) => boolean, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>>>]>>>;
|
|
7
|
+
}, z.core.$strict>;
|
|
18
8
|
export declare const injectPartial: z.ZodObject<{
|
|
19
9
|
compileSrc: z.ZodDefault<z.ZodBoolean>;
|
|
20
10
|
swDest: z.ZodOptional<z.ZodString>;
|
|
21
|
-
webpackCompilationPlugins: z.ZodOptional<z.ZodArray<z.ZodAny
|
|
22
|
-
},
|
|
23
|
-
compileSrc: boolean;
|
|
24
|
-
webpackCompilationPlugins?: any[] | undefined;
|
|
25
|
-
swDest?: string | undefined;
|
|
26
|
-
}, {
|
|
27
|
-
compileSrc?: boolean | undefined;
|
|
28
|
-
webpackCompilationPlugins?: any[] | undefined;
|
|
29
|
-
swDest?: string | undefined;
|
|
30
|
-
}>;
|
|
11
|
+
webpackCompilationPlugins: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
12
|
+
}, z.core.$strict>;
|
|
31
13
|
export declare const injectManifestOptions: z.ZodObject<{
|
|
32
|
-
|
|
14
|
+
compileSrc: z.ZodDefault<z.ZodBoolean>;
|
|
15
|
+
swDest: z.ZodOptional<z.ZodString>;
|
|
16
|
+
webpackCompilationPlugins: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
17
|
+
injectionPoint: z.ZodDefault<z.ZodString>;
|
|
18
|
+
swSrc: z.ZodString;
|
|
19
|
+
chunks: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
20
|
+
exclude: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<RegExp, RegExp>, z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>>, z.ZodTransform<(args_0: any) => boolean, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>>>]>>>;
|
|
21
|
+
excludeChunks: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
22
|
+
include: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<RegExp, RegExp>, z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>>, z.ZodTransform<(args_0: any) => boolean, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>>>]>>>;
|
|
23
|
+
additionalPrecacheEntries: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
33
24
|
integrity: z.ZodOptional<z.ZodString>;
|
|
34
25
|
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
35
26
|
url: z.ZodString;
|
|
36
|
-
},
|
|
37
|
-
url: string;
|
|
38
|
-
integrity?: string | undefined;
|
|
39
|
-
revision?: string | null | undefined;
|
|
40
|
-
}, {
|
|
41
|
-
url: string;
|
|
42
|
-
integrity?: string | undefined;
|
|
43
|
-
revision?: string | null | undefined;
|
|
44
|
-
}>]>, "many">>;
|
|
27
|
+
}, z.core.$strict>]>>>;
|
|
45
28
|
disablePrecacheManifest: z.ZodDefault<z.ZodBoolean>;
|
|
46
|
-
dontCacheBustURLsMatching: z.ZodOptional<z.
|
|
47
|
-
manifestTransforms: z.ZodOptional<z.ZodArray<z.
|
|
29
|
+
dontCacheBustURLsMatching: z.ZodOptional<z.ZodCustom<RegExp, RegExp>>;
|
|
30
|
+
manifestTransforms: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
31
|
+
size: z.ZodNumber;
|
|
48
32
|
integrity: z.ZodOptional<z.ZodString>;
|
|
49
33
|
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
50
34
|
url: z.ZodString;
|
|
51
|
-
}
|
|
52
|
-
size: z.ZodNumber;
|
|
53
|
-
}, "strip", z.ZodTypeAny, {
|
|
54
|
-
url: string;
|
|
55
|
-
size: number;
|
|
56
|
-
integrity?: string | undefined;
|
|
57
|
-
revision?: string | null | undefined;
|
|
58
|
-
}, {
|
|
59
|
-
url: string;
|
|
60
|
-
size: number;
|
|
61
|
-
integrity?: string | undefined;
|
|
62
|
-
revision?: string | null | undefined;
|
|
63
|
-
}>, "many">, z.ZodOptional<z.ZodUnknown>], null>, z.ZodUnion<[z.ZodPromise<z.ZodObject<{
|
|
35
|
+
}, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
|
|
64
36
|
manifest: z.ZodArray<z.ZodObject<{
|
|
37
|
+
size: z.ZodNumber;
|
|
65
38
|
integrity: z.ZodOptional<z.ZodString>;
|
|
66
39
|
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
67
40
|
url: z.ZodString;
|
|
68
|
-
}
|
|
41
|
+
}, z.core.$strip>>;
|
|
42
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
43
|
+
}, z.core.$strict>>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
44
|
+
size: z.ZodNumber;
|
|
45
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
46
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
47
|
+
url: z.ZodString;
|
|
48
|
+
}, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
|
|
49
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
69
50
|
size: z.ZodNumber;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
82
|
-
}, "strict", z.ZodTypeAny, {
|
|
83
|
-
manifest: {
|
|
84
|
-
url: string;
|
|
85
|
-
size: number;
|
|
86
|
-
integrity?: string | undefined;
|
|
87
|
-
revision?: string | null | undefined;
|
|
88
|
-
}[];
|
|
89
|
-
warnings?: string[] | undefined;
|
|
90
|
-
}, {
|
|
91
|
-
manifest: {
|
|
92
|
-
url: string;
|
|
93
|
-
size: number;
|
|
94
|
-
integrity?: string | undefined;
|
|
95
|
-
revision?: string | null | undefined;
|
|
96
|
-
}[];
|
|
97
|
-
warnings?: string[] | undefined;
|
|
98
|
-
}>>, z.ZodObject<{
|
|
51
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
52
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
53
|
+
url: z.ZodString;
|
|
54
|
+
}, z.core.$strip>>;
|
|
55
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
56
|
+
}, z.core.$strict>>>, z.ZodTransform<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
57
|
+
size: z.ZodNumber;
|
|
58
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
59
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
60
|
+
url: z.ZodString;
|
|
61
|
+
}, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
|
|
99
62
|
manifest: z.ZodArray<z.ZodObject<{
|
|
63
|
+
size: z.ZodNumber;
|
|
100
64
|
integrity: z.ZodOptional<z.ZodString>;
|
|
101
65
|
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
102
66
|
url: z.ZodString;
|
|
103
|
-
}
|
|
67
|
+
}, z.core.$strip>>;
|
|
68
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
69
|
+
}, z.core.$strict>>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
70
|
+
size: z.ZodNumber;
|
|
71
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
72
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
73
|
+
url: z.ZodString;
|
|
74
|
+
}, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
|
|
75
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
104
76
|
size: z.ZodNumber;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
url: string;
|
|
112
|
-
size: number;
|
|
113
|
-
integrity?: string | undefined;
|
|
114
|
-
revision?: string | null | undefined;
|
|
115
|
-
}>, "many">;
|
|
116
|
-
warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
117
|
-
}, "strict", z.ZodTypeAny, {
|
|
118
|
-
manifest: {
|
|
119
|
-
url: string;
|
|
120
|
-
size: number;
|
|
121
|
-
integrity?: string | undefined;
|
|
122
|
-
revision?: string | null | undefined;
|
|
123
|
-
}[];
|
|
124
|
-
warnings?: string[] | undefined;
|
|
125
|
-
}, {
|
|
126
|
-
manifest: {
|
|
127
|
-
url: string;
|
|
128
|
-
size: number;
|
|
129
|
-
integrity?: string | undefined;
|
|
130
|
-
revision?: string | null | undefined;
|
|
131
|
-
}[];
|
|
132
|
-
warnings?: string[] | undefined;
|
|
133
|
-
}>]>>, "many">>;
|
|
77
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
78
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
79
|
+
url: z.ZodString;
|
|
80
|
+
}, z.core.$strip>>;
|
|
81
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
82
|
+
}, z.core.$strict>>>>>>;
|
|
134
83
|
maximumFileSizeToCacheInBytes: z.ZodDefault<z.ZodNumber>;
|
|
135
84
|
modifyURLPrefix: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
136
|
-
|
|
137
|
-
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">>;
|
|
138
|
-
excludeChunks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
139
|
-
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">>;
|
|
140
|
-
injectionPoint: z.ZodDefault<z.ZodString>;
|
|
141
|
-
swSrc: z.ZodString;
|
|
142
|
-
} & {
|
|
143
|
-
compileSrc: z.ZodDefault<z.ZodBoolean>;
|
|
144
|
-
swDest: z.ZodOptional<z.ZodString>;
|
|
145
|
-
webpackCompilationPlugins: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
146
|
-
}, "strict", z.ZodTypeAny, {
|
|
147
|
-
exclude: (string | RegExp | ((args_0: any) => boolean))[];
|
|
148
|
-
compileSrc: boolean;
|
|
149
|
-
disablePrecacheManifest: boolean;
|
|
150
|
-
maximumFileSizeToCacheInBytes: number;
|
|
151
|
-
injectionPoint: string;
|
|
152
|
-
swSrc: string;
|
|
153
|
-
chunks?: string[] | undefined;
|
|
154
|
-
excludeChunks?: string[] | undefined;
|
|
155
|
-
include?: (string | RegExp | ((args_0: any) => boolean))[] | undefined;
|
|
156
|
-
webpackCompilationPlugins?: any[] | undefined;
|
|
157
|
-
additionalPrecacheEntries?: (string | {
|
|
158
|
-
url: string;
|
|
159
|
-
integrity?: string | undefined;
|
|
160
|
-
revision?: string | null | undefined;
|
|
161
|
-
})[] | undefined;
|
|
162
|
-
dontCacheBustURLsMatching?: RegExp | undefined;
|
|
163
|
-
manifestTransforms?: ((args_0: {
|
|
164
|
-
url: string;
|
|
165
|
-
size: number;
|
|
166
|
-
integrity?: string | undefined;
|
|
167
|
-
revision?: string | null | undefined;
|
|
168
|
-
}[], args_1: unknown) => {
|
|
169
|
-
manifest: {
|
|
170
|
-
url: string;
|
|
171
|
-
size: number;
|
|
172
|
-
integrity?: string | undefined;
|
|
173
|
-
revision?: string | null | undefined;
|
|
174
|
-
}[];
|
|
175
|
-
warnings?: string[] | undefined;
|
|
176
|
-
} | Promise<{
|
|
177
|
-
manifest: {
|
|
178
|
-
url: string;
|
|
179
|
-
size: number;
|
|
180
|
-
integrity?: string | undefined;
|
|
181
|
-
revision?: string | null | undefined;
|
|
182
|
-
}[];
|
|
183
|
-
warnings?: string[] | undefined;
|
|
184
|
-
}>)[] | undefined;
|
|
185
|
-
modifyURLPrefix?: Record<string, string> | undefined;
|
|
186
|
-
swDest?: string | undefined;
|
|
187
|
-
}, {
|
|
188
|
-
swSrc: string;
|
|
189
|
-
exclude?: (string | RegExp | ((args_0: any) => boolean))[] | undefined;
|
|
190
|
-
chunks?: string[] | undefined;
|
|
191
|
-
excludeChunks?: string[] | undefined;
|
|
192
|
-
include?: (string | RegExp | ((args_0: any) => boolean))[] | undefined;
|
|
193
|
-
compileSrc?: boolean | undefined;
|
|
194
|
-
webpackCompilationPlugins?: any[] | undefined;
|
|
195
|
-
disablePrecacheManifest?: boolean | undefined;
|
|
196
|
-
maximumFileSizeToCacheInBytes?: number | undefined;
|
|
197
|
-
injectionPoint?: string | undefined;
|
|
198
|
-
additionalPrecacheEntries?: (string | {
|
|
199
|
-
url: string;
|
|
200
|
-
integrity?: string | undefined;
|
|
201
|
-
revision?: string | null | undefined;
|
|
202
|
-
})[] | undefined;
|
|
203
|
-
dontCacheBustURLsMatching?: RegExp | undefined;
|
|
204
|
-
manifestTransforms?: ((args_0: {
|
|
205
|
-
url: string;
|
|
206
|
-
size: number;
|
|
207
|
-
integrity?: string | undefined;
|
|
208
|
-
revision?: string | null | undefined;
|
|
209
|
-
}[], args_1: unknown) => {
|
|
210
|
-
manifest: {
|
|
211
|
-
url: string;
|
|
212
|
-
size: number;
|
|
213
|
-
integrity?: string | undefined;
|
|
214
|
-
revision?: string | null | undefined;
|
|
215
|
-
}[];
|
|
216
|
-
warnings?: string[] | undefined;
|
|
217
|
-
} | Promise<{
|
|
218
|
-
manifest: {
|
|
219
|
-
url: string;
|
|
220
|
-
size: number;
|
|
221
|
-
integrity?: string | undefined;
|
|
222
|
-
revision?: string | null | undefined;
|
|
223
|
-
}[];
|
|
224
|
-
warnings?: string[] | undefined;
|
|
225
|
-
}>)[] | undefined;
|
|
226
|
-
modifyURLPrefix?: Record<string, string> | undefined;
|
|
227
|
-
swDest?: string | undefined;
|
|
228
|
-
}>;
|
|
85
|
+
}, z.core.$strict>;
|
|
229
86
|
//# sourceMappingURL=schema.d.ts.map
|
package/dist/lib/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/lib/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/lib/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,eAAO,MAAM,cAAc;;;;;kBAKzB,CAAC;AAEH,eAAO,MAAM,aAAa;;;;kBAIxB,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAMhC,CAAC"}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { InjectPartial as BaseInjectPartial, InjectResolved as BaseInjectResolved, BasePartial, BaseResolved, OptionalSwDestPartial, OptionalSwDestResolved } from "@serwist/build";
|
|
2
2
|
import type { Prettify, Require } from "@serwist/utils";
|
|
3
|
-
import type {
|
|
3
|
+
import type { Asset, Compilation, WebpackPluginFunction, WebpackPluginInstance } from "webpack";
|
|
4
4
|
export interface ConditionCallbackOptions {
|
|
5
5
|
asset: Asset;
|
|
6
6
|
compilation: Compilation;
|
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,IAAI,iBAAiB,EAClC,cAAc,IAAI,kBAAkB,EACpC,WAAW,EACX,YAAY,EACZ,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,IAAI,iBAAiB,EAClC,cAAc,IAAI,kBAAkB,EACpC,WAAW,EACX,YAAY,EACZ,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEhG,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,KAAK,CAAC;IACb,WAAW,EAAE,WAAW,CAAC;CAC1B;AAED,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,wBAAwB,KAAK,OAAO,CAAC;AAE/E,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,iBAAiB,CAAC,EAAE,CAAC;IAClD;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,iBAAiB,CAAC,EAAE,CAAC;CACnD;AAED,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC,CAAC;AAE3E,MAAM,WAAW,aAAa;IAC5B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAIrB;;;OAGG;IACH,yBAAyB,CAAC,EAAE,aAAa,EAAE,CAAC;CAC7C;AAED,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC;AAE5E,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC,WAAW,GAAG,cAAc,GAAG,iBAAiB,GAAG,qBAAqB,GAAG,aAAa,CAAC,CAAC;AAEvI,MAAM,MAAM,6BAA6B,GAAG,QAAQ,CAAC,YAAY,GAAG,eAAe,GAAG,kBAAkB,GAAG,sBAAsB,GAAG,cAAc,CAAC,CAAC;AAEpJ,MAAM,MAAM,aAAa,GAAG,qBAAqB,GAAG,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/webpack-plugin",
|
|
3
|
-
"version": "10.0.0-preview.
|
|
3
|
+
"version": "10.0.0-preview.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "A plugin for your webpack build process, helping you generate a manifest of local files that should be precached.",
|
|
@@ -59,18 +59,18 @@
|
|
|
59
59
|
"./package.json": "./package.json"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"pretty-bytes": "
|
|
63
|
-
"zod": "
|
|
64
|
-
"@serwist/build": "10.0.0-preview.
|
|
65
|
-
"@serwist/utils": "10.0.0-preview.
|
|
62
|
+
"pretty-bytes": "7.0.0",
|
|
63
|
+
"zod": "4.0.5",
|
|
64
|
+
"@serwist/build": "10.0.0-preview.9",
|
|
65
|
+
"@serwist/utils": "10.0.0-preview.9"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@types/node": "
|
|
68
|
+
"@types/node": "24.0.14",
|
|
69
69
|
"@types/webpack": "5.28.5",
|
|
70
|
-
"rollup": "4.
|
|
70
|
+
"rollup": "4.45.1",
|
|
71
71
|
"typescript": "5.8.3",
|
|
72
|
-
"webpack": "5.
|
|
73
|
-
"@serwist/configs": "10.0.0-preview.
|
|
72
|
+
"webpack": "5.100.2",
|
|
73
|
+
"@serwist/configs": "10.0.0-preview.9"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
76
|
"typescript": ">=5.0.0",
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
license that can be found in the LICENSE file or at
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
import type { ManifestEntry } from "@serwist/build";
|
|
10
10
|
import { transformManifest } from "@serwist/build";
|
|
11
|
+
import type { FileDetails } from "@serwist/utils";
|
|
11
12
|
import type { Asset, Chunk, Compilation, WebpackError } from "webpack";
|
|
12
13
|
|
|
13
14
|
import { getAssetHash } from "./get-asset-hash.js";
|
|
@@ -25,18 +26,15 @@ import type { InjectManifestOptions, InjectManifestOptionsComplete } from "./typ
|
|
|
25
26
|
* @returns Whether or not at least one condition matches.
|
|
26
27
|
* @private
|
|
27
28
|
*/
|
|
28
|
-
const checkConditions = (
|
|
29
|
-
|
|
30
|
-
compilation: Compilation,
|
|
29
|
+
const checkConditions = (asset: Asset, compilation: Compilation, conditions: Array<string | RegExp | ((arg0: any) => boolean)> = []): boolean => {
|
|
30
|
+
const matchPart = compilation.compiler.webpack.ModuleFilenameHelpers.matchPart;
|
|
31
31
|
|
|
32
|
-
conditions: Array<string | RegExp | ((arg0: any) => boolean)> = [],
|
|
33
|
-
): boolean => {
|
|
34
32
|
for (const condition of conditions) {
|
|
35
33
|
if (typeof condition === "function") {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (
|
|
34
|
+
if (condition({ asset, compilation })) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
} else if (matchPart(asset.name, condition)) {
|
|
40
38
|
return true;
|
|
41
39
|
}
|
|
42
40
|
}
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
license that can be found in the LICENSE file or at
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
import path from "node:path";
|
|
10
|
+
import { toUnix } from "@serwist/utils";
|
|
10
11
|
import type { Compilation } from "webpack";
|
|
11
12
|
|
|
12
13
|
/**
|
package/src/lib/schema.ts
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
import { injectPartial as baseInjectPartial, basePartial, optionalSwDestPartial } from "@serwist/build/schema";
|
|
1
|
+
import { injectPartial as baseInjectPartial, basePartial, fn, optionalSwDestPartial } from "@serwist/build/schema";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
.
|
|
6
|
-
|
|
7
|
-
|
|
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!");
|
|
4
|
+
const webpackConditionCallback = fn({
|
|
5
|
+
input: [z.any()],
|
|
6
|
+
output: z.boolean(),
|
|
7
|
+
});
|
|
14
8
|
|
|
15
|
-
|
|
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!");
|
|
9
|
+
const webpackCondition = z.union([z.string(), z.instanceof(RegExp), webpackConditionCallback]);
|
|
22
10
|
|
|
23
|
-
export const
|
|
24
|
-
.
|
|
25
|
-
.
|
|
26
|
-
.
|
|
27
|
-
.
|
|
28
|
-
|
|
11
|
+
export const webpackPartial = z.strictObject({
|
|
12
|
+
chunks: z.array(z.string()).optional(),
|
|
13
|
+
exclude: z.array(webpackCondition).default([/\.map$/, /^manifest.*\.js$/]),
|
|
14
|
+
excludeChunks: z.array(z.string()).optional(),
|
|
15
|
+
include: z.array(webpackCondition).optional(),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const injectPartial = z.strictObject({
|
|
19
|
+
compileSrc: z.boolean().default(true),
|
|
20
|
+
swDest: z.string().optional(),
|
|
21
|
+
webpackCompilationPlugins: z.array(z.any()).optional(),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const injectManifestOptions = z.strictObject({
|
|
25
|
+
...basePartial.shape,
|
|
26
|
+
...webpackPartial.shape,
|
|
27
|
+
...baseInjectPartial.shape,
|
|
28
|
+
...optionalSwDestPartial.shape,
|
|
29
|
+
...injectPartial.shape,
|
|
30
|
+
});
|
package/src/lib/types.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
OptionalSwDestResolved,
|
|
8
8
|
} from "@serwist/build";
|
|
9
9
|
import type { Prettify, Require } from "@serwist/utils";
|
|
10
|
-
import type {
|
|
10
|
+
import type { Asset, Compilation, WebpackPluginFunction, WebpackPluginInstance } from "webpack";
|
|
11
11
|
|
|
12
12
|
export interface ConditionCallbackOptions {
|
|
13
13
|
asset: Asset;
|
package/src/lib/validator.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { SerwistConfigError, validationErrorMap } from "@serwist/build/schema";
|
|
|
2
2
|
import type { InjectManifestOptionsComplete } from "./types.js";
|
|
3
3
|
|
|
4
4
|
export const validateInjectManifestOptions = async (input: unknown): Promise<InjectManifestOptionsComplete> => {
|
|
5
|
-
const result = await (await import("./schema.js")).injectManifestOptions.spa(input, {
|
|
5
|
+
const result = await (await import("./schema.js")).injectManifestOptions.spa(input, { error: validationErrorMap });
|
|
6
6
|
if (!result.success) {
|
|
7
7
|
throw new SerwistConfigError({ moduleName: "@serwist/webpack-plugin", message: JSON.stringify(result.error.format(), null, 2) });
|
|
8
8
|
}
|