@serwist/webpack-plugin 9.0.0-preview.16 → 9.0.0-preview.18

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/index.js CHANGED
@@ -135,7 +135,8 @@ const getManifestEntriesFromCompilation = async (compilation, config)=>{
135
135
  manifestTransforms: config.manifestTransforms,
136
136
  maximumFileSizeToCacheInBytes: config.maximumFileSizeToCacheInBytes,
137
137
  modifyURLPrefix: config.modifyURLPrefix,
138
- transformParam: compilation
138
+ transformParam: compilation,
139
+ disablePrecacheManifest: config.disablePrecacheManifest
139
140
  });
140
141
  for (const warning of warnings){
141
142
  compilation.warnings.push(new Error(warning));
@@ -1,5 +1,5 @@
1
1
  import type { Compiler } from "webpack";
2
- import type { InjectManifestOptions } from "./lib/types.js";
2
+ import type { InjectManifestOptions, InjectManifestOptionsComplete } 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,7 +23,7 @@ import type { InjectManifestOptions } from "./lib/types.js";
23
23
  * ```
24
24
  */
25
25
  export declare class InjectManifest {
26
- protected config: InjectManifestOptions;
26
+ protected config: InjectManifestOptionsComplete;
27
27
  private alreadyCalled;
28
28
  private webpack;
29
29
  /**
@@ -1 +1 @@
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
+ {"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,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;IAOzC;;;;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,7 +1,7 @@
1
1
  import type { ManifestEntry } from "@serwist/build";
2
2
  import type { Compilation } from "webpack";
3
- import type { InjectManifestOptions } from "./types.js";
4
- export declare const getManifestEntriesFromCompilation: (compilation: Compilation, config: InjectManifestOptions) => Promise<{
3
+ import type { InjectManifestOptionsComplete } from "./types.js";
4
+ export declare const getManifestEntriesFromCompilation: (compilation: Compilation, config: InjectManifestOptionsComplete) => Promise<{
5
5
  size: number;
6
6
  sortedEntries: ManifestEntry[] | undefined;
7
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,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"}
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;UACpB,MAAM;mBAAiB,aAAa,EAAE,GAAG,SAAS;EAiCpE,CAAC"}
@@ -35,100 +35,100 @@ export declare const injectManifestOptions: z.ZodObject<{
35
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
36
  additionalPrecacheEntries: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
37
37
  integrity: z.ZodOptional<z.ZodString>;
38
- revision: z.ZodNullable<z.ZodString>;
38
+ revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
39
39
  url: z.ZodString;
40
40
  }, "strict", z.ZodTypeAny, {
41
- revision: string | null;
42
41
  url: string;
43
42
  integrity?: string | undefined;
43
+ revision?: string | null | undefined;
44
44
  }, {
45
- revision: string | null;
46
45
  url: string;
47
46
  integrity?: string | undefined;
47
+ revision?: string | null | undefined;
48
48
  }>]>, "many">>;
49
49
  disablePrecacheManifest: z.ZodDefault<z.ZodBoolean>;
50
50
  dontCacheBustURLsMatching: z.ZodOptional<z.ZodType<RegExp, z.ZodTypeDef, RegExp>>;
51
51
  manifestTransforms: z.ZodOptional<z.ZodArray<z.ZodFunction<z.ZodTuple<[z.ZodArray<z.ZodObject<{
52
52
  integrity: z.ZodOptional<z.ZodString>;
53
- revision: z.ZodNullable<z.ZodString>;
53
+ revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
54
54
  url: z.ZodString;
55
55
  size: z.ZodNumber;
56
56
  }, "strip", z.ZodTypeAny, {
57
- revision: string | null;
58
57
  url: string;
59
58
  size: number;
60
59
  integrity?: string | undefined;
60
+ revision?: string | null | undefined;
61
61
  }, {
62
- revision: string | null;
63
62
  url: string;
64
63
  size: number;
65
64
  integrity?: string | undefined;
65
+ revision?: string | null | undefined;
66
66
  }>, "many">, z.ZodOptional<z.ZodUnknown>], null>, z.ZodUnion<[z.ZodPromise<z.ZodObject<{
67
67
  manifest: z.ZodArray<z.ZodObject<{
68
68
  integrity: z.ZodOptional<z.ZodString>;
69
- revision: z.ZodNullable<z.ZodString>;
69
+ revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
70
70
  url: z.ZodString;
71
71
  size: z.ZodNumber;
72
72
  }, "strip", z.ZodTypeAny, {
73
- revision: string | null;
74
73
  url: string;
75
74
  size: number;
76
75
  integrity?: string | undefined;
76
+ revision?: string | null | undefined;
77
77
  }, {
78
- revision: string | null;
79
78
  url: string;
80
79
  size: number;
81
80
  integrity?: string | undefined;
81
+ revision?: string | null | undefined;
82
82
  }>, "many">;
83
83
  warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
84
84
  }, "strict", z.ZodTypeAny, {
85
85
  manifest: {
86
- revision: string | null;
87
86
  url: string;
88
87
  size: number;
89
88
  integrity?: string | undefined;
89
+ revision?: string | null | undefined;
90
90
  }[];
91
91
  warnings?: string[] | undefined;
92
92
  }, {
93
93
  manifest: {
94
- revision: string | null;
95
94
  url: string;
96
95
  size: number;
97
96
  integrity?: string | undefined;
97
+ revision?: string | null | undefined;
98
98
  }[];
99
99
  warnings?: string[] | undefined;
100
100
  }>>, z.ZodObject<{
101
101
  manifest: z.ZodArray<z.ZodObject<{
102
102
  integrity: z.ZodOptional<z.ZodString>;
103
- revision: z.ZodNullable<z.ZodString>;
103
+ revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
104
104
  url: z.ZodString;
105
105
  size: z.ZodNumber;
106
106
  }, "strip", z.ZodTypeAny, {
107
- revision: string | null;
108
107
  url: string;
109
108
  size: number;
110
109
  integrity?: string | undefined;
110
+ revision?: string | null | undefined;
111
111
  }, {
112
- revision: string | null;
113
112
  url: string;
114
113
  size: number;
115
114
  integrity?: string | undefined;
115
+ revision?: string | null | undefined;
116
116
  }>, "many">;
117
117
  warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
118
118
  }, "strict", z.ZodTypeAny, {
119
119
  manifest: {
120
- revision: string | null;
121
120
  url: string;
122
121
  size: number;
123
122
  integrity?: string | undefined;
123
+ revision?: string | null | undefined;
124
124
  }[];
125
125
  warnings?: string[] | undefined;
126
126
  }, {
127
127
  manifest: {
128
- revision: string | null;
129
128
  url: string;
130
129
  size: number;
131
130
  integrity?: string | undefined;
131
+ revision?: string | null | undefined;
132
132
  }[];
133
133
  warnings?: string[] | undefined;
134
134
  }>]>>, "many">>;
@@ -150,30 +150,30 @@ export declare const injectManifestOptions: z.ZodObject<{
150
150
  excludeChunks?: string[] | undefined;
151
151
  include?: (string | RegExp | ((args_0: any) => boolean))[] | undefined;
152
152
  additionalPrecacheEntries?: (string | {
153
- revision: string | null;
154
153
  url: string;
155
154
  integrity?: string | undefined;
155
+ revision?: string | null | undefined;
156
156
  })[] | undefined;
157
157
  dontCacheBustURLsMatching?: RegExp | undefined;
158
158
  manifestTransforms?: ((args_0: {
159
- revision: string | null;
160
159
  url: string;
161
160
  size: number;
162
161
  integrity?: string | undefined;
162
+ revision?: string | null | undefined;
163
163
  }[], args_1: unknown) => {
164
164
  manifest: {
165
- revision: string | null;
166
165
  url: string;
167
166
  size: number;
168
167
  integrity?: string | undefined;
168
+ revision?: string | null | undefined;
169
169
  }[];
170
170
  warnings?: string[] | undefined;
171
171
  } | Promise<{
172
172
  manifest: {
173
- revision: string | null;
174
173
  url: string;
175
174
  size: number;
176
175
  integrity?: string | undefined;
176
+ revision?: string | null | undefined;
177
177
  }[];
178
178
  warnings?: string[] | undefined;
179
179
  }>)[] | undefined;
@@ -187,31 +187,31 @@ export declare const injectManifestOptions: z.ZodObject<{
187
187
  excludeChunks?: string[] | undefined;
188
188
  include?: (string | RegExp | ((args_0: any) => boolean))[] | undefined;
189
189
  additionalPrecacheEntries?: (string | {
190
- revision: string | null;
191
190
  url: string;
192
191
  integrity?: string | undefined;
192
+ revision?: string | null | undefined;
193
193
  })[] | undefined;
194
194
  disablePrecacheManifest?: boolean | undefined;
195
195
  dontCacheBustURLsMatching?: RegExp | undefined;
196
196
  manifestTransforms?: ((args_0: {
197
- revision: string | null;
198
197
  url: string;
199
198
  size: number;
200
199
  integrity?: string | undefined;
200
+ revision?: string | null | undefined;
201
201
  }[], args_1: unknown) => {
202
202
  manifest: {
203
- revision: string | null;
204
203
  url: string;
205
204
  size: number;
206
205
  integrity?: string | undefined;
206
+ revision?: string | null | undefined;
207
207
  }[];
208
208
  warnings?: string[] | undefined;
209
209
  } | Promise<{
210
210
  manifest: {
211
- revision: string | null;
212
211
  url: string;
213
212
  size: number;
214
213
  integrity?: string | undefined;
214
+ revision?: string | null | undefined;
215
215
  }[];
216
216
  warnings?: string[] | undefined;
217
217
  }>)[] | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serwist/webpack-plugin",
3
- "version": "9.0.0-preview.16",
3
+ "version": "9.0.0-preview.18",
4
4
  "type": "module",
5
5
  "description": "A plugin for your webpack build process, helping you generate a manifest of local files that should be precached.",
6
6
  "files": [
@@ -56,7 +56,7 @@
56
56
  "pretty-bytes": "6.1.1",
57
57
  "upath": "2.0.1",
58
58
  "zod": "3.22.4",
59
- "@serwist/build": "9.0.0-preview.16"
59
+ "@serwist/build": "9.0.0-preview.18"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@types/node": "20.11.30",
@@ -64,8 +64,8 @@
64
64
  "rollup": "4.13.0",
65
65
  "typescript": "5.5.0-dev.20240323",
66
66
  "webpack": "5.91.0",
67
- "@serwist/constants": "9.0.0-preview.16",
68
- "@serwist/utils": "9.0.0-preview.16"
67
+ "@serwist/constants": "9.0.0-preview.18",
68
+ "@serwist/utils": "9.0.0-preview.18"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "typescript": ">=5.0.0",
@@ -2,7 +2,7 @@ import { escapeRegExp, replaceAndUpdateSourceMap, stringify } from "@serwist/bui
2
2
  import prettyBytes from "pretty-bytes";
3
3
  import upath from "upath";
4
4
  import type { Compilation, Compiler, WebpackError, default as Webpack } from "webpack";
5
- import type { InjectManifestOptions } from "./lib/types.js";
5
+ import type { InjectManifestOptions, InjectManifestOptionsComplete } from "./lib/types.js";
6
6
  import { validateInjectManifestOptions } from "./lib/validator.js";
7
7
 
8
8
  import { getManifestEntriesFromCompilation } from "./lib/get-manifest-entries-from-compilation.js";
@@ -36,7 +36,7 @@ const _generatedAssetNames = new Set<string>();
36
36
  * ```
37
37
  */
38
38
  export class InjectManifest {
39
- protected config: InjectManifestOptions;
39
+ protected config: InjectManifestOptionsComplete;
40
40
  private alreadyCalled: boolean;
41
41
  private webpack: typeof Webpack;
42
42
 
@@ -44,7 +44,8 @@ export class InjectManifest {
44
44
  * Creates an instance of InjectManifest.
45
45
  */
46
46
  constructor(config: InjectManifestOptions) {
47
- this.config = config;
47
+ // We are essentially lying to TypeScript.
48
+ this.config = config as InjectManifestOptionsComplete;
48
49
  this.alreadyCalled = false;
49
50
  this.webpack = null!;
50
51
  }
@@ -72,7 +73,7 @@ export class InjectManifest {
72
73
  *
73
74
  * @private
74
75
  */
75
- private async getManifestEntries(compilation: Compilation, config: InjectManifestOptions) {
76
+ private async getManifestEntries(compilation: Compilation, config: InjectManifestOptionsComplete) {
76
77
  if (config.disablePrecacheManifest) {
77
78
  return {
78
79
  size: 0,
@@ -236,7 +237,7 @@ export class InjectManifest {
236
237
  const swAsset = compilation.getAsset(config.swDest!);
237
238
  const swAssetString = swAsset!.source.source().toString();
238
239
 
239
- const globalRegexp = new RegExp(escapeRegExp(config.injectionPoint!), "g");
240
+ const globalRegexp = new RegExp(escapeRegExp(config.injectionPoint), "g");
240
241
  const injectionResults = swAssetString.match(globalRegexp);
241
242
 
242
243
  if (!injectionResults) {
@@ -12,7 +12,7 @@ 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
+ import type { InjectManifestOptions, InjectManifestOptionsComplete } from "./types.js";
16
16
 
17
17
  /**
18
18
  * For a given asset, checks whether at least one of the conditions matches.
@@ -178,7 +178,7 @@ const filterAssets = (compilation: Compilation, config: InjectManifestOptions):
178
178
 
179
179
  export const getManifestEntriesFromCompilation = async (
180
180
  compilation: Compilation,
181
- config: InjectManifestOptions,
181
+ config: InjectManifestOptionsComplete,
182
182
  ): Promise<{ size: number; sortedEntries: ManifestEntry[] | undefined }> => {
183
183
  const filteredAssets = filterAssets(compilation, config);
184
184
 
@@ -189,7 +189,7 @@ export const getManifestEntriesFromCompilation = async (
189
189
  file: resolveWebpackURL(publicPath as string, asset.name),
190
190
  hash: getAssetHash(asset),
191
191
  size: asset.source.size() || 0,
192
- } as FileDetails;
192
+ } satisfies FileDetails;
193
193
  });
194
194
 
195
195
  const { manifestEntries, size, warnings } = await transformManifest({
@@ -200,6 +200,7 @@ export const getManifestEntriesFromCompilation = async (
200
200
  maximumFileSizeToCacheInBytes: config.maximumFileSizeToCacheInBytes,
201
201
  modifyURLPrefix: config.modifyURLPrefix,
202
202
  transformParam: compilation,
203
+ disablePrecacheManifest: config.disablePrecacheManifest,
203
204
  });
204
205
 
205
206
  // See https://github.com/GoogleChrome/workbox/issues/2790