@serwist/webpack-plugin 8.4.0 → 8.4.2
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.cjs +17 -20
- package/dist/index.js +17 -20
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -120,7 +120,7 @@ function prettyBytes(number, options) {
|
|
|
120
120
|
// If webpack has the asset marked as immutable, then we don't need to
|
|
121
121
|
// use an out-of-band revision for it.
|
|
122
122
|
// See https://github.com/webpack/webpack/issues/9038
|
|
123
|
-
if (asset.info
|
|
123
|
+
if (asset.info?.immutable) {
|
|
124
124
|
return null;
|
|
125
125
|
}
|
|
126
126
|
return crypto.createHash("md5").update(Buffer.from(asset.source.source())).digest("hex");
|
|
@@ -147,12 +147,11 @@ function prettyBytes(number, options) {
|
|
|
147
147
|
// See https://github.com/jantimon/html-webpack-plugin/pull/1516
|
|
148
148
|
if (publicPath === "auto") {
|
|
149
149
|
return paths.join("");
|
|
150
|
-
} else {
|
|
151
|
-
return [
|
|
152
|
-
publicPath,
|
|
153
|
-
...paths
|
|
154
|
-
].join("");
|
|
155
150
|
}
|
|
151
|
+
return [
|
|
152
|
+
publicPath,
|
|
153
|
+
...paths
|
|
154
|
+
].join("");
|
|
156
155
|
}
|
|
157
156
|
|
|
158
157
|
/**
|
|
@@ -173,10 +172,9 @@ function prettyBytes(number, options) {
|
|
|
173
172
|
compilation
|
|
174
173
|
});
|
|
175
174
|
//return compilation !== null;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
175
|
+
}
|
|
176
|
+
if (webpack.ModuleFilenameHelpers.matchPart(asset.name, condition)) {
|
|
177
|
+
return true;
|
|
180
178
|
}
|
|
181
179
|
}
|
|
182
180
|
// We'll only get here if none of the conditions applied.
|
|
@@ -193,18 +191,17 @@ function prettyBytes(number, options) {
|
|
|
193
191
|
* @returns
|
|
194
192
|
* @private
|
|
195
193
|
*/ function getNamesOfAssetsInChunkOrGroup(compilation, chunkOrGroup) {
|
|
196
|
-
const chunkGroup = compilation.namedChunkGroups
|
|
194
|
+
const chunkGroup = compilation.namedChunkGroups?.get(chunkOrGroup);
|
|
197
195
|
if (chunkGroup) {
|
|
198
196
|
const assetNames = [];
|
|
199
197
|
for (const chunk of chunkGroup.chunks){
|
|
200
198
|
assetNames.push(...getNamesOfAssetsInChunk(chunk));
|
|
201
199
|
}
|
|
202
200
|
return assetNames;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
201
|
+
}
|
|
202
|
+
const chunk = compilation.namedChunks?.get(chunkOrGroup);
|
|
203
|
+
if (chunk) {
|
|
204
|
+
return getNamesOfAssetsInChunk(chunk);
|
|
208
205
|
}
|
|
209
206
|
// If we get here, there's no chunkGroup or chunk with that name.
|
|
210
207
|
return null;
|
|
@@ -248,7 +245,7 @@ function prettyBytes(number, options) {
|
|
|
248
245
|
allowedAssetNames.add(assetName);
|
|
249
246
|
}
|
|
250
247
|
} else {
|
|
251
|
-
compilation.warnings.push(new Error(`The chunk '${name}' was
|
|
248
|
+
compilation.warnings.push(new Error(`The chunk '${name}' was provided in your Serwist chunks config, but was not found in the compilation.`));
|
|
252
249
|
}
|
|
253
250
|
}
|
|
254
251
|
}
|
|
@@ -402,7 +399,7 @@ const _generatedAssetNames = new Set();
|
|
|
402
399
|
this.config = Object.assign({
|
|
403
400
|
mode: compiler.options.mode,
|
|
404
401
|
// Use swSrc with a hardcoded .js extension, in case swSrc is a .ts file.
|
|
405
|
-
swDest: parsedSwSrc.name
|
|
402
|
+
swDest: `${parsedSwSrc.name}.js`
|
|
406
403
|
}, this.config);
|
|
407
404
|
}
|
|
408
405
|
/**
|
|
@@ -419,7 +416,7 @@ const _generatedAssetNames = new Set();
|
|
|
419
416
|
}
|
|
420
417
|
// See https://github.com/GoogleChrome/workbox/issues/1790
|
|
421
418
|
if (this.alreadyCalled) {
|
|
422
|
-
const warningMessage = `${this.constructor.name} has been called
|
|
419
|
+
const warningMessage = `${this.constructor.name} has been called multiple times, perhaps due to running webpack in --watch mode. The precache manifest generated after the first call may be inaccurate! Please see https://github.com/GoogleChrome/workbox/issues/1790 for more information.`;
|
|
423
420
|
if (!compilation.warnings.some((warning)=>warning instanceof Error && warning.message === warningMessage)) {
|
|
424
421
|
compilation.warnings.push(new Error(warningMessage));
|
|
425
422
|
}
|
|
@@ -551,7 +548,7 @@ const _generatedAssetNames = new Set();
|
|
|
551
548
|
throw new Error(`Can't find ${config.injectionPoint} in your SW source.`);
|
|
552
549
|
}
|
|
553
550
|
if (injectionResults.length !== 1) {
|
|
554
|
-
throw new Error(`Multiple instances of ${config.injectionPoint} were
|
|
551
|
+
throw new Error(`Multiple instances of ${config.injectionPoint} were found in your SW source. Include it only once. For more info, see https://github.com/GoogleChrome/workbox/issues/2681`);
|
|
555
552
|
}
|
|
556
553
|
const sourcemapAssetName = getSourcemapAssetName(compilation, swAssetString, config.swDest);
|
|
557
554
|
if (sourcemapAssetName) {
|
package/dist/index.js
CHANGED
|
@@ -118,7 +118,7 @@ function prettyBytes(number, options) {
|
|
|
118
118
|
// If webpack has the asset marked as immutable, then we don't need to
|
|
119
119
|
// use an out-of-band revision for it.
|
|
120
120
|
// See https://github.com/webpack/webpack/issues/9038
|
|
121
|
-
if (asset.info
|
|
121
|
+
if (asset.info?.immutable) {
|
|
122
122
|
return null;
|
|
123
123
|
}
|
|
124
124
|
return crypto.createHash("md5").update(Buffer.from(asset.source.source())).digest("hex");
|
|
@@ -145,12 +145,11 @@ function prettyBytes(number, options) {
|
|
|
145
145
|
// See https://github.com/jantimon/html-webpack-plugin/pull/1516
|
|
146
146
|
if (publicPath === "auto") {
|
|
147
147
|
return paths.join("");
|
|
148
|
-
} else {
|
|
149
|
-
return [
|
|
150
|
-
publicPath,
|
|
151
|
-
...paths
|
|
152
|
-
].join("");
|
|
153
148
|
}
|
|
149
|
+
return [
|
|
150
|
+
publicPath,
|
|
151
|
+
...paths
|
|
152
|
+
].join("");
|
|
154
153
|
}
|
|
155
154
|
|
|
156
155
|
/**
|
|
@@ -171,10 +170,9 @@ function prettyBytes(number, options) {
|
|
|
171
170
|
compilation
|
|
172
171
|
});
|
|
173
172
|
//return compilation !== null;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
173
|
+
}
|
|
174
|
+
if (webpack.ModuleFilenameHelpers.matchPart(asset.name, condition)) {
|
|
175
|
+
return true;
|
|
178
176
|
}
|
|
179
177
|
}
|
|
180
178
|
// We'll only get here if none of the conditions applied.
|
|
@@ -191,18 +189,17 @@ function prettyBytes(number, options) {
|
|
|
191
189
|
* @returns
|
|
192
190
|
* @private
|
|
193
191
|
*/ function getNamesOfAssetsInChunkOrGroup(compilation, chunkOrGroup) {
|
|
194
|
-
const chunkGroup = compilation.namedChunkGroups
|
|
192
|
+
const chunkGroup = compilation.namedChunkGroups?.get(chunkOrGroup);
|
|
195
193
|
if (chunkGroup) {
|
|
196
194
|
const assetNames = [];
|
|
197
195
|
for (const chunk of chunkGroup.chunks){
|
|
198
196
|
assetNames.push(...getNamesOfAssetsInChunk(chunk));
|
|
199
197
|
}
|
|
200
198
|
return assetNames;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
199
|
+
}
|
|
200
|
+
const chunk = compilation.namedChunks?.get(chunkOrGroup);
|
|
201
|
+
if (chunk) {
|
|
202
|
+
return getNamesOfAssetsInChunk(chunk);
|
|
206
203
|
}
|
|
207
204
|
// If we get here, there's no chunkGroup or chunk with that name.
|
|
208
205
|
return null;
|
|
@@ -246,7 +243,7 @@ function prettyBytes(number, options) {
|
|
|
246
243
|
allowedAssetNames.add(assetName);
|
|
247
244
|
}
|
|
248
245
|
} else {
|
|
249
|
-
compilation.warnings.push(new Error(`The chunk '${name}' was
|
|
246
|
+
compilation.warnings.push(new Error(`The chunk '${name}' was provided in your Serwist chunks config, but was not found in the compilation.`));
|
|
250
247
|
}
|
|
251
248
|
}
|
|
252
249
|
}
|
|
@@ -400,7 +397,7 @@ const _generatedAssetNames = new Set();
|
|
|
400
397
|
this.config = Object.assign({
|
|
401
398
|
mode: compiler.options.mode,
|
|
402
399
|
// Use swSrc with a hardcoded .js extension, in case swSrc is a .ts file.
|
|
403
|
-
swDest: parsedSwSrc.name
|
|
400
|
+
swDest: `${parsedSwSrc.name}.js`
|
|
404
401
|
}, this.config);
|
|
405
402
|
}
|
|
406
403
|
/**
|
|
@@ -417,7 +414,7 @@ const _generatedAssetNames = new Set();
|
|
|
417
414
|
}
|
|
418
415
|
// See https://github.com/GoogleChrome/workbox/issues/1790
|
|
419
416
|
if (this.alreadyCalled) {
|
|
420
|
-
const warningMessage = `${this.constructor.name} has been called
|
|
417
|
+
const warningMessage = `${this.constructor.name} has been called multiple times, perhaps due to running webpack in --watch mode. The precache manifest generated after the first call may be inaccurate! Please see https://github.com/GoogleChrome/workbox/issues/1790 for more information.`;
|
|
421
418
|
if (!compilation.warnings.some((warning)=>warning instanceof Error && warning.message === warningMessage)) {
|
|
422
419
|
compilation.warnings.push(new Error(warningMessage));
|
|
423
420
|
}
|
|
@@ -549,7 +546,7 @@ const _generatedAssetNames = new Set();
|
|
|
549
546
|
throw new Error(`Can't find ${config.injectionPoint} in your SW source.`);
|
|
550
547
|
}
|
|
551
548
|
if (injectionResults.length !== 1) {
|
|
552
|
-
throw new Error(`Multiple instances of ${config.injectionPoint} were
|
|
549
|
+
throw new Error(`Multiple instances of ${config.injectionPoint} were found in your SW source. Include it only once. For more info, see https://github.com/GoogleChrome/workbox/issues/2681`);
|
|
553
550
|
}
|
|
554
551
|
const sourcemapAssetName = getSourcemapAssetName(compilation, swAssetString, config.swDest);
|
|
555
552
|
if (sourcemapAssetName) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/webpack-plugin",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.2",
|
|
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": [
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"fast-json-stable-stringify": "2.1.0",
|
|
63
63
|
"upath": "2.0.1",
|
|
64
|
-
"@serwist/build": "8.4.
|
|
64
|
+
"@serwist/build": "8.4.2"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"webpack": "4.4.0 || ^5.9.0"
|
|
@@ -71,12 +71,12 @@
|
|
|
71
71
|
"@types/webpack": "5.28.5",
|
|
72
72
|
"pretty-bytes": "6.1.1",
|
|
73
73
|
"rollup": "4.9.1",
|
|
74
|
-
"@serwist/constants": "8.4.
|
|
74
|
+
"@serwist/constants": "8.4.2"
|
|
75
75
|
},
|
|
76
76
|
"scripts": {
|
|
77
77
|
"build": "rimraf dist && cross-env NODE_ENV=production rollup --config rollup.config.js",
|
|
78
78
|
"dev": "rollup --config rollup.config.js --watch",
|
|
79
|
-
"lint": "
|
|
79
|
+
"lint": "biome lint ./src",
|
|
80
80
|
"typecheck": "tsc"
|
|
81
81
|
}
|
|
82
82
|
}
|