@serwist/webpack-plugin 10.0.0-preview.1 → 10.0.0-preview.10

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.
@@ -1,11 +1,5 @@
1
1
  import path from 'node:path';
2
-
3
- const relativeToOutputPath = (compilation, originalPath)=>{
4
- if (path.resolve(originalPath) === path.normalize(originalPath)) {
5
- return path.relative(compilation.options.output.path, originalPath);
6
- }
7
- return originalPath;
8
- };
2
+ import { toUnix } from '@serwist/utils';
9
3
 
10
4
  const performChildCompilation = async (compiler, compilation, name, src, dest, plugins)=>{
11
5
  const childCompiler = compilation.createChildCompiler(name, {
@@ -30,4 +24,11 @@ const performChildCompilation = async (compiler, compilation, name, src, dest, p
30
24
  });
31
25
  };
32
26
 
27
+ const relativeToOutputPath = (compilation, originalPath)=>{
28
+ if (path.resolve(originalPath) === path.normalize(originalPath)) {
29
+ return toUnix(path.relative(compilation.options.output.path, originalPath));
30
+ }
31
+ return originalPath;
32
+ };
33
+
33
34
  export { performChildCompilation as p, relativeToOutputPath as r };
@@ -1,32 +1,37 @@
1
- import { basePartial, injectPartial as injectPartial$1, optionalSwDestPartial } from '@serwist/build/schema';
1
+ import { fn, optionalSwDestPartial, injectPartial as injectPartial$1, basePartial } from '@serwist/build/schema';
2
2
  import { z } from 'zod';
3
3
 
4
- const webpackPartial = z.object({
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(z.union([
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(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({
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
- }).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!");
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 };
@@ -1,5 +1,6 @@
1
- import { p as performChildCompilation, r as relativeToOutputPath } from './chunks/perform-child-compilation.js';
1
+ import { p as performChildCompilation, r as relativeToOutputPath } from './chunks/relative-to-output-path.js';
2
2
  import 'node:path';
3
+ import '@serwist/utils';
3
4
 
4
5
  class ChildCompilationPlugin {
5
6
  src;
package/dist/index.js CHANGED
@@ -2,28 +2,15 @@ import path from 'node:path';
2
2
  import { transformManifest, getSourceMapURL, escapeRegExp, replaceAndUpdateSourceMap } from '@serwist/build';
3
3
  import { toUnix } from '@serwist/utils';
4
4
  import prettyBytes from 'pretty-bytes';
5
- import { validationErrorMap, SerwistConfigError } from '@serwist/build/schema';
6
5
  import crypto from 'node:crypto';
7
- import { r as relativeToOutputPath, p as performChildCompilation } from './chunks/perform-child-compilation.js';
8
-
9
- const validateInjectManifestOptions = async (input)=>{
10
- const result = await (await import('./chunks/schema.js')).injectManifestOptions.spa(input, {
11
- errorMap: validationErrorMap
12
- });
13
- if (!result.success) {
14
- throw new SerwistConfigError({
15
- moduleName: "@serwist/webpack-plugin",
16
- message: JSON.stringify(result.error.format(), null, 2)
17
- });
18
- }
19
- return result.data;
20
- };
6
+ import { r as relativeToOutputPath, p as performChildCompilation } from './chunks/relative-to-output-path.js';
7
+ import { validationErrorMap, SerwistConfigError } from '@serwist/build/schema';
21
8
 
22
9
  const getAssetHash = (asset)=>{
23
10
  if (asset.info?.immutable) {
24
11
  return null;
25
12
  }
26
- return crypto.createHash("md5").update(Buffer.from(asset.source.source())).digest("hex");
13
+ return crypto.createHash("md5").update(asset.source.source()).digest("hex");
27
14
  };
28
15
 
29
16
  const resolveWebpackURL = (publicPath, ...paths)=>{
@@ -37,14 +24,16 @@ const resolveWebpackURL = (publicPath, ...paths)=>{
37
24
  };
38
25
 
39
26
  const checkConditions = (asset, compilation, conditions = [])=>{
27
+ const matchPart = compilation.compiler.webpack.ModuleFilenameHelpers.matchPart;
40
28
  for (const condition of conditions){
41
29
  if (typeof condition === "function") {
42
- return condition({
30
+ if (condition({
43
31
  asset,
44
32
  compilation
45
- });
46
- }
47
- if (compilation.compiler.webpack.ModuleFilenameHelpers.matchPart(asset.name, condition)) {
33
+ })) {
34
+ return true;
35
+ }
36
+ } else if (matchPart(asset.name, condition)) {
48
37
  return true;
49
38
  }
50
39
  }
@@ -161,6 +150,19 @@ const getSourcemapAssetName = (compilation, swContents, swDest)=>{
161
150
  return undefined;
162
151
  };
163
152
 
153
+ const validateInjectManifestOptions = async (input)=>{
154
+ const result = await (await import('./chunks/schema.js')).injectManifestOptions.spa(input, {
155
+ error: validationErrorMap
156
+ });
157
+ if (!result.success) {
158
+ throw new SerwistConfigError({
159
+ moduleName: "@serwist/webpack-plugin",
160
+ message: JSON.stringify(result.error.format(), null, 2)
161
+ });
162
+ }
163
+ return result.data;
164
+ };
165
+
164
166
  const _generatedAssetNames = new Set();
165
167
  class InjectManifest {
166
168
  config;
@@ -1 +1 @@
1
- {"version":3,"file":"inject-manifest.d.ts","sourceRoot":"","sources":["../src/inject-manifest.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAe,QAAQ,EAAoC,MAAM,SAAS,CAAC;AACvF,OAAO,KAAK,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAW3F;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,cAAc;IACzB,SAAS,CAAC,MAAM,EAAE,6BAA6B,CAAC;IAChD,OAAO,CAAC,aAAa,CAAU;IAC/B,OAAO,CAAC,OAAO,CAAiB;IAEhC;;OAEG;gBACS,MAAM,EAAE,qBAAqB;IAQzC;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAa9B;;;;OAIG;YACW,kBAAkB;IAuChC;;;;OAIG;IACH,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IA6B/B;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAKtB;;;;;OAKG;YACW,UAAU;IAwBxB;;;;OAIG;YACW,SAAS;CAiDxB"}
1
+ {"version":3,"file":"inject-manifest.d.ts","sourceRoot":"","sources":["../src/inject-manifest.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAe,QAAQ,EAAoC,MAAM,SAAS,CAAC;AAKvF,OAAO,KAAK,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAO3F;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,cAAc;IACzB,SAAS,CAAC,MAAM,EAAE,6BAA6B,CAAC;IAChD,OAAO,CAAC,aAAa,CAAU;IAC/B,OAAO,CAAC,OAAO,CAAiB;IAEhC;;OAEG;gBACS,MAAM,EAAE,qBAAqB;IAQzC;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAa9B;;;;OAIG;YACW,kBAAkB;IAuChC;;;;OAIG;IACH,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IA6B/B;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAKtB;;;;;OAKG;YACW,UAAU;IAwBxB;;;;OAIG;YACW,SAAS;CAiDxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-asset-hash.d.ts","sourceRoot":"","sources":["../../src/lib/get-asset-hash.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC;;;;;GAKG;AACH,eAAO,MAAM,YAAY,UAAW,KAAK,KAAG,MAAM,GAAG,IASpD,CAAC"}
1
+ {"version":3,"file":"get-asset-hash.d.ts","sourceRoot":"","sources":["../../src/lib/get-asset-hash.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,KAAK,KAAG,MAAM,GAAG,IASpD,CAAC"}
@@ -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;AAEjE,OAAO,KAAK,EAAgB,WAAW,EAAgB,MAAM,SAAS,CAAC;AAIvE,OAAO,KAAK,EAAyB,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAoKvF,eAAO,MAAM,iCAAiC,gBAC/B,WAAW,UAChB,6BAA6B,KACpC,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,aAAa,EAAE,GAAG,SAAS,CAAA;CAAE,CAiCtE,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":"get-script-files-for-chunks.d.ts","sourceRoot":"","sources":["../../src/lib/get-script-files-for-chunks.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,SAAS,CAAC;AAIzD,eAAO,MAAM,uBAAuB,gBAAiB,WAAW,cAAc,MAAM,EAAE,KAAG,MAAM,EAwB9F,CAAC"}
1
+ {"version":3,"file":"get-script-files-for-chunks.d.ts","sourceRoot":"","sources":["../../src/lib/get-script-files-for-chunks.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,SAAS,CAAC;AAIzD,eAAO,MAAM,uBAAuB,GAAI,aAAa,WAAW,EAAE,YAAY,MAAM,EAAE,KAAG,MAAM,EAwB9F,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-sourcemap-asset-name.d.ts","sourceRoot":"","sources":["../../src/lib/get-sourcemap-asset-name.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,qBAAqB,gBAAiB,WAAW,cAAc,MAAM,UAAU,MAAM,KAAG,MAAM,GAAG,SAgB7G,CAAC"}
1
+ {"version":3,"file":"get-sourcemap-asset-name.d.ts","sourceRoot":"","sources":["../../src/lib/get-sourcemap-asset-name.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,qBAAqB,GAAI,aAAa,WAAW,EAAE,YAAY,MAAM,EAAE,QAAQ,MAAM,KAAG,MAAM,GAAG,SAgB7G,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"perform-child-compilation.d.ts","sourceRoot":"","sources":["../../src/lib/perform-child-compilation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,aACxB,QAAQ,eACL,WAAW,QAClB,MAAM,OACP,MAAM,QACL,MAAM,WACH,aAAa,EAAE,GAAG,SAAS,kBAuBrC,CAAC"}
1
+ {"version":3,"file":"perform-child-compilation.d.ts","sourceRoot":"","sources":["../../src/lib/perform-child-compilation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,GAClC,UAAU,QAAQ,EAClB,aAAa,WAAW,EACxB,MAAM,MAAM,EACZ,KAAK,MAAM,EACX,MAAM,MAAM,EACZ,SAAS,aAAa,EAAE,GAAG,SAAS,kBAuBrC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"relative-to-output-path.d.ts","sourceRoot":"","sources":["../../src/lib/relative-to-output-path.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,gBAAiB,WAAW,gBAAgB,MAAM,KAAG,MAQrF,CAAC"}
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"}
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-webpack-url.d.ts","sourceRoot":"","sources":["../../src/lib/resolve-webpack-url.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,eAAgB,MAAM,YAAY,MAAM,EAAE,KAAG,MAO1E,CAAC"}
1
+ {"version":3,"file":"resolve-webpack-url.d.ts","sourceRoot":"","sources":["../../src/lib/resolve-webpack-url.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,GAAI,YAAY,MAAM,EAAE,GAAG,OAAO,MAAM,EAAE,KAAG,MAO1E,CAAC"}
@@ -1,233 +1,86 @@
1
1
  import { z } from "zod";
2
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
- 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, "many">>;
22
- }, "strict", z.ZodTypeAny, {
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
- }>;
31
- export declare const injectManifestOptions: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<z.objectUtil.extendShape<z.objectUtil.extendShape<{
32
- additionalPrecacheEntries: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
11
+ webpackCompilationPlugins: z.ZodOptional<z.ZodArray<z.ZodAny>>;
12
+ }, z.core.$strict>;
13
+ export declare const injectManifestOptions: z.ZodObject<{
14
+ compileSrc: z.ZodDefault<z.ZodBoolean>;
15
+ swDest: z.ZodOptional<z.ZodString>;
16
+ webpackCompilationPlugins: z.ZodOptional<z.ZodArray<z.ZodAny>>;
17
+ injectionPoint: z.ZodPrefault<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
- }, "strict", z.ZodTypeAny, {
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.ZodType<RegExp, z.ZodTypeDef, RegExp>>;
47
- manifestTransforms: z.ZodOptional<z.ZodArray<z.ZodFunction<z.ZodTuple<[z.ZodArray<z.ZodObject<z.objectUtil.extendShape<{
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
- }, {
35
+ }, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
36
+ manifest: z.ZodArray<z.ZodObject<{
37
+ size: z.ZodNumber;
38
+ integrity: z.ZodOptional<z.ZodString>;
39
+ revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
40
+ url: z.ZodString;
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<{
52
44
  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<{
64
- manifest: z.ZodArray<z.ZodObject<z.objectUtil.extendShape<{
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<{
50
+ size: z.ZodNumber;
65
51
  integrity: z.ZodOptional<z.ZodString>;
66
52
  revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
67
53
  url: z.ZodString;
68
- }, {
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<{
62
+ manifest: z.ZodArray<z.ZodObject<{
69
63
  size: z.ZodNumber;
70
- }>, "strip", z.ZodTypeAny, {
71
- url: string;
72
- size: number;
73
- integrity?: string | undefined;
74
- revision?: string | null | undefined;
75
- }, {
76
- url: string;
77
- size: number;
78
- integrity?: string | undefined;
79
- revision?: string | null | undefined;
80
- }>, "many">;
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<{
99
- manifest: z.ZodArray<z.ZodObject<z.objectUtil.extendShape<{
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
- }>, "strip", z.ZodTypeAny, {
106
- url: string;
107
- size: number;
108
- integrity?: string | undefined;
109
- revision?: string | null | undefined;
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
- chunks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
138
- 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">>;
139
- excludeChunks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
140
- 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">>;
141
- }>, {
142
- injectionPoint: z.ZodDefault<z.ZodString>;
143
- swSrc: z.ZodString;
144
- }>, {
145
- swDest: z.ZodOptional<z.ZodString>;
146
- }>, {
147
- compileSrc: z.ZodDefault<z.ZodBoolean>;
148
- swDest: z.ZodOptional<z.ZodString>;
149
- webpackCompilationPlugins: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
150
- }>, "strict", z.ZodTypeAny, {
151
- exclude: (string | RegExp | ((args_0: any) => boolean))[];
152
- compileSrc: boolean;
153
- disablePrecacheManifest: boolean;
154
- maximumFileSizeToCacheInBytes: number;
155
- injectionPoint: string;
156
- swSrc: string;
157
- chunks?: string[] | undefined;
158
- excludeChunks?: string[] | undefined;
159
- include?: (string | RegExp | ((args_0: any) => boolean))[] | undefined;
160
- webpackCompilationPlugins?: any[] | undefined;
161
- additionalPrecacheEntries?: (string | {
162
- url: string;
163
- integrity?: string | undefined;
164
- revision?: string | null | undefined;
165
- })[] | undefined;
166
- dontCacheBustURLsMatching?: RegExp | undefined;
167
- manifestTransforms?: ((args_0: {
168
- url: string;
169
- size: number;
170
- integrity?: string | undefined;
171
- revision?: string | null | undefined;
172
- }[], args_1: unknown) => {
173
- manifest: {
174
- url: string;
175
- size: number;
176
- integrity?: string | undefined;
177
- revision?: string | null | undefined;
178
- }[];
179
- warnings?: string[] | undefined;
180
- } | Promise<{
181
- manifest: {
182
- url: string;
183
- size: number;
184
- integrity?: string | undefined;
185
- revision?: string | null | undefined;
186
- }[];
187
- warnings?: string[] | undefined;
188
- }>)[] | undefined;
189
- modifyURLPrefix?: Record<string, string> | undefined;
190
- swDest?: string | undefined;
191
- }, {
192
- swSrc: string;
193
- exclude?: (string | RegExp | ((args_0: any) => boolean))[] | undefined;
194
- chunks?: string[] | undefined;
195
- excludeChunks?: string[] | undefined;
196
- include?: (string | RegExp | ((args_0: any) => boolean))[] | undefined;
197
- compileSrc?: boolean | undefined;
198
- webpackCompilationPlugins?: any[] | undefined;
199
- disablePrecacheManifest?: boolean | undefined;
200
- maximumFileSizeToCacheInBytes?: number | undefined;
201
- injectionPoint?: string | undefined;
202
- additionalPrecacheEntries?: (string | {
203
- url: string;
204
- integrity?: string | undefined;
205
- revision?: string | null | undefined;
206
- })[] | undefined;
207
- dontCacheBustURLsMatching?: RegExp | undefined;
208
- manifestTransforms?: ((args_0: {
209
- url: string;
210
- size: number;
211
- integrity?: string | undefined;
212
- revision?: string | null | undefined;
213
- }[], args_1: unknown) => {
214
- manifest: {
215
- url: string;
216
- size: number;
217
- integrity?: string | undefined;
218
- revision?: string | null | undefined;
219
- }[];
220
- warnings?: string[] | undefined;
221
- } | Promise<{
222
- manifest: {
223
- url: string;
224
- size: number;
225
- integrity?: string | undefined;
226
- revision?: string | null | undefined;
227
- }[];
228
- warnings?: string[] | undefined;
229
- }>)[] | undefined;
230
- modifyURLPrefix?: Record<string, string> | undefined;
231
- swDest?: string | undefined;
232
- }>;
85
+ }, z.core.$strict>;
233
86
  //# sourceMappingURL=schema.d.ts.map
@@ -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;AAExB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;EASmC,CAAC;AAE/D,eAAO,MAAM,aAAa;;;;;;;;;;;;EAMkD,CAAC;AAE7E,eAAO,MAAM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O,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAMhC,CAAC"}
@@ -1,6 +1,11 @@
1
- import type { BasePartial, BaseResolved, InjectPartial as BaseInjectPartial, InjectResolved as BaseInjectResolved, OptionalSwDestPartial, OptionalSwDestResolved } from "@serwist/build";
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 { WebpackPluginFunction, WebpackPluginInstance } from "webpack";
3
+ import type { Asset, Compilation, WebpackPluginFunction, WebpackPluginInstance } from "webpack";
4
+ export interface ConditionCallbackOptions {
5
+ asset: Asset;
6
+ compilation: Compilation;
7
+ }
8
+ export type ConditionCallback = (options: ConditionCallbackOptions) => boolean;
4
9
  export interface WebpackPartial {
5
10
  /**
6
11
  * One or more chunk names whose corresponding output files should be included
@@ -17,7 +22,7 @@ export interface WebpackPartial {
17
22
  * [/\.map$/, /^manifest.*\.js$/]
18
23
  * ```
19
24
  */
20
- exclude?: (string | RegExp | ((arg0: any) => boolean))[];
25
+ exclude?: (string | RegExp | ConditionCallback)[];
21
26
  /**
22
27
  * One or more chunk names whose corresponding output files should be excluded
23
28
  * from the precache manifest.
@@ -29,7 +34,7 @@ export interface WebpackPartial {
29
34
  * [the same rules](https://webpack.js.org/configuration/module/#condition)
30
35
  * as webpack's standard `include` option.
31
36
  */
32
- include?: (string | RegExp | ((arg0: any) => boolean))[];
37
+ include?: (string | RegExp | ConditionCallback)[];
33
38
  }
34
39
  export type WebpackResolved = Prettify<Require<WebpackPartial, "exclude">>;
35
40
  export interface InjectPartial {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,E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AAO,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"}
@@ -1 +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,OAAO,CAAC,6BAA6B,CAMzG,CAAC"}
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,GAAU,OAAO,OAAO,KAAG,OAAO,CAAC,6BAA6B,CAMzG,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@serwist/webpack-plugin",
3
- "version": "10.0.0-preview.1",
3
+ "version": "10.0.0-preview.10",
4
4
  "type": "module",
5
+ "sideEffects": false,
5
6
  "description": "A plugin for your webpack build process, helping you generate a manifest of local files that should be precached.",
6
7
  "files": [
7
8
  "src",
@@ -20,7 +21,7 @@
20
21
  "file manifest"
21
22
  ],
22
23
  "engines": {
23
- "node": ">=18.0.0"
24
+ "node": ">=20.0.0"
24
25
  },
25
26
  "author": "Google's Web DevRel Team",
26
27
  "contributors": [
@@ -58,18 +59,18 @@
58
59
  "./package.json": "./package.json"
59
60
  },
60
61
  "dependencies": {
61
- "pretty-bytes": "6.1.1",
62
- "zod": "3.24.2",
63
- "@serwist/build": "10.0.0-preview.1",
64
- "@serwist/utils": "10.0.0-preview.1"
62
+ "pretty-bytes": "7.0.0",
63
+ "zod": "4.0.5",
64
+ "@serwist/build": "10.0.0-preview.10",
65
+ "@serwist/utils": "10.0.0-preview.10"
65
66
  },
66
67
  "devDependencies": {
67
- "@types/node": "22.13.5",
68
+ "@types/node": "24.0.14",
68
69
  "@types/webpack": "5.28.5",
69
- "rollup": "4.34.8",
70
- "typescript": "5.7.3",
71
- "webpack": "5.98.0",
72
- "@serwist/configs": "10.0.0-preview.1"
70
+ "rollup": "4.45.1",
71
+ "typescript": "5.8.3",
72
+ "webpack": "5.100.2",
73
+ "@serwist/configs": "10.0.0-preview.10"
73
74
  },
74
75
  "peerDependencies": {
75
76
  "typescript": ">=5.0.0",
@@ -87,6 +88,7 @@
87
88
  "build": "rimraf dist && NODE_ENV=production rollup --config rollup.config.js",
88
89
  "dev": "rollup --config rollup.config.js --watch",
89
90
  "lint": "biome lint ./src",
91
+ "qcheck": "biome check ./src",
90
92
  "typecheck": "tsc"
91
93
  }
92
94
  }
@@ -2,13 +2,13 @@ import path from "node:path";
2
2
  import { escapeRegExp, replaceAndUpdateSourceMap } from "@serwist/build";
3
3
  import { toUnix } from "@serwist/utils";
4
4
  import prettyBytes from "pretty-bytes";
5
- import type { Compilation, Compiler, WebpackError, default as Webpack } from "webpack";
6
- import type { InjectManifestOptions, InjectManifestOptionsComplete } from "./lib/types.js";
7
- import { validateInjectManifestOptions } from "./lib/validator.js";
5
+ import type { Compilation, Compiler, default as Webpack, WebpackError } from "webpack";
8
6
  import { getManifestEntriesFromCompilation } from "./lib/get-manifest-entries-from-compilation.js";
9
7
  import { getSourcemapAssetName } from "./lib/get-sourcemap-asset-name.js";
10
- import { relativeToOutputPath } from "./lib/relative-to-output-path.js";
11
8
  import { performChildCompilation } from "./lib/perform-child-compilation.js";
9
+ import { relativeToOutputPath } from "./lib/relative-to-output-path.js";
10
+ import type { InjectManifestOptions, InjectManifestOptionsComplete } from "./lib/types.js";
11
+ import { validateInjectManifestOptions } from "./lib/validator.js";
12
12
 
13
13
  // Used to keep track of swDest files written by *any* instance of this plugin.
14
14
  // See https://github.com/GoogleChrome/workbox/issues/2181
@@ -1,7 +1,7 @@
1
1
  import type { Compiler, WebpackError, WebpackPluginInstance } from "webpack";
2
2
 
3
- import { relativeToOutputPath } from "./relative-to-output-path.js";
4
3
  import { performChildCompilation } from "./perform-child-compilation.js";
4
+ import { relativeToOutputPath } from "./relative-to-output-path.js";
5
5
 
6
6
  export interface ChildCompilationPluginOptions {
7
7
  src: string;
@@ -23,5 +23,5 @@ export const getAssetHash = (asset: Asset): string | null => {
23
23
  return null;
24
24
  }
25
25
 
26
- return crypto.createHash("md5").update(Buffer.from(asset.source.source())).digest("hex");
26
+ return crypto.createHash("md5").update(asset.source.source()).digest("hex");
27
27
  };
@@ -6,8 +6,9 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import type { FileDetails, ManifestEntry } from "@serwist/build";
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
- asset: Asset,
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
- return condition({ asset, compilation });
37
- //return compilation !== null;
38
- }
39
- if (compilation.compiler.webpack.ModuleFilenameHelpers.matchPart(asset.name, condition)) {
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,7 +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
  import path from "node:path";
10
+ import { toUnix } from "@serwist/utils";
9
11
  import type { Compilation } from "webpack";
10
12
 
11
13
  /**
@@ -20,7 +22,7 @@ import type { Compilation } from "webpack";
20
22
  export const relativeToOutputPath = (compilation: Compilation, originalPath: string): string => {
21
23
  // See https://github.com/jantimon/html-webpack-plugin/pull/266/files#diff-168726dbe96b3ce427e7fedce31bb0bcR38
22
24
  if (path.resolve(originalPath) === path.normalize(originalPath)) {
23
- return path.relative(compilation.options.output.path!, originalPath);
25
+ return toUnix(path.relative(compilation.options.output.path!, originalPath));
24
26
  }
25
27
 
26
28
  // Otherwise, return swDest as-is.
package/src/lib/schema.ts CHANGED
@@ -1,28 +1,30 @@
1
- import { basePartial, injectPartial as baseInjectPartial, 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
- 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!");
4
+ const webpackConditionCallback = fn({
5
+ input: [z.any()],
6
+ output: z.boolean(),
7
+ });
14
8
 
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!");
9
+ const webpackCondition = z.union([z.string(), z.instanceof(RegExp), webpackConditionCallback]);
22
10
 
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!");
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
@@ -1,13 +1,20 @@
1
1
  import type {
2
- BasePartial,
3
- BaseResolved,
4
2
  InjectPartial as BaseInjectPartial,
5
3
  InjectResolved as BaseInjectResolved,
4
+ BasePartial,
5
+ BaseResolved,
6
6
  OptionalSwDestPartial,
7
7
  OptionalSwDestResolved,
8
8
  } from "@serwist/build";
9
9
  import type { Prettify, Require } from "@serwist/utils";
10
- import type { WebpackPluginFunction, WebpackPluginInstance } from "webpack";
10
+ import type { Asset, Compilation, WebpackPluginFunction, WebpackPluginInstance } from "webpack";
11
+
12
+ export interface ConditionCallbackOptions {
13
+ asset: Asset;
14
+ compilation: Compilation;
15
+ }
16
+
17
+ export type ConditionCallback = (options: ConditionCallbackOptions) => boolean;
11
18
 
12
19
  export interface WebpackPartial {
13
20
  /**
@@ -25,7 +32,7 @@ export interface WebpackPartial {
25
32
  * [/\.map$/, /^manifest.*\.js$/]
26
33
  * ```
27
34
  */
28
- exclude?: (string | RegExp | ((arg0: any) => boolean))[];
35
+ exclude?: (string | RegExp | ConditionCallback)[];
29
36
  /**
30
37
  * One or more chunk names whose corresponding output files should be excluded
31
38
  * from the precache manifest.
@@ -37,7 +44,7 @@ export interface WebpackPartial {
37
44
  * [the same rules](https://webpack.js.org/configuration/module/#condition)
38
45
  * as webpack's standard `include` option.
39
46
  */
40
- include?: (string | RegExp | ((arg0: any) => boolean))[];
47
+ include?: (string | RegExp | ConditionCallback)[];
41
48
  }
42
49
 
43
50
  export type WebpackResolved = Prettify<Require<WebpackPartial, "exclude">>;
@@ -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, { errorMap: validationErrorMap });
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
  }