webpack 5.76.0 → 5.76.1

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.

Potentially problematic release.


This version of webpack might be problematic. Click here for more details.

@@ -11,6 +11,7 @@ const ExternalsPlugin = require("../ExternalsPlugin");
11
11
 
12
12
  const builtins = [
13
13
  "assert",
14
+ "assert/strict",
14
15
  "async_hooks",
15
16
  "buffer",
16
17
  "child_process",
@@ -178,43 +178,10 @@ class RealContentHashPlugin {
178
178
  }
179
179
  }
180
180
  if (hashToAssets.size === 0) return;
181
- const hashRegExps = Array.from(hashToAssets.keys(), quoteMeta).map(
182
- hash => new RegExp(hash, "g")
181
+ const hashRegExp = new RegExp(
182
+ Array.from(hashToAssets.keys(), quoteMeta).join("|"),
183
+ "g"
183
184
  );
184
-
185
- /**
186
- * @param {string} str string to be matched against all hashRegExps
187
- * @returns {string[] | null} matches found
188
- */
189
- const hashMatch = str => {
190
- /** @type {string[]} */
191
- const results = [];
192
- for (const hashRegExp of hashRegExps) {
193
- const matches = str.match(hashRegExp);
194
- if (matches) {
195
- matches.forEach(match => results.push(match));
196
- }
197
- }
198
- if (results.length) {
199
- return results;
200
- } else {
201
- return null;
202
- }
203
- };
204
-
205
- /**
206
- * @param {string} str string to be replaced with all hashRegExps
207
- * @param {function(string): string} fn replacement function to use when a hash is found
208
- * @returns {string} replaced content
209
- */
210
- const hashReplace = (str, fn) => {
211
- let result = str;
212
- for (const hashRegExp of hashRegExps) {
213
- result = result.replace(hashRegExp, fn);
214
- }
215
- return result;
216
- };
217
-
218
185
  await Promise.all(
219
186
  assetsWithInfo.map(async asset => {
220
187
  const { name, source, content, hashes } = asset;
@@ -231,7 +198,7 @@ class RealContentHashPlugin {
231
198
  await cacheAnalyse.providePromise(name, etag, () => {
232
199
  const referencedHashes = new Set();
233
200
  let ownHashes = new Set();
234
- const inContent = hashMatch(content);
201
+ const inContent = content.match(hashRegExp);
235
202
  if (inContent) {
236
203
  for (const hash of inContent) {
237
204
  if (hashes.has(hash)) {
@@ -331,7 +298,7 @@ ${referencingAssets
331
298
  identifier,
332
299
  etag,
333
300
  () => {
334
- const newContent = hashReplace(asset.content, hash =>
301
+ const newContent = asset.content.replace(hashRegExp, hash =>
335
302
  hashToNewHash.get(hash)
336
303
  );
337
304
  return new RawSource(newContent);
@@ -356,12 +323,15 @@ ${referencingAssets
356
323
  identifier,
357
324
  etag,
358
325
  () => {
359
- const newContent = hashReplace(asset.content, hash => {
360
- if (asset.ownHashes.has(hash)) {
361
- return "";
326
+ const newContent = asset.content.replace(
327
+ hashRegExp,
328
+ hash => {
329
+ if (asset.ownHashes.has(hash)) {
330
+ return "";
331
+ }
332
+ return hashToNewHash.get(hash);
362
333
  }
363
- return hashToNewHash.get(hash);
364
- });
334
+ );
365
335
  return new RawSource(newContent);
366
336
  }
367
337
  );
@@ -393,6 +363,9 @@ ${referencingAssets
393
363
  let newHash = hooks.updateHash.call(assetsContent, oldHash);
394
364
  if (!newHash) {
395
365
  const hash = createHash(this._hashFunction);
366
+ if (compilation.outputOptions.hashSalt) {
367
+ hash.update(compilation.outputOptions.hashSalt);
368
+ }
396
369
  for (const content of assetsContent) {
397
370
  hash.update(content);
398
371
  }
@@ -404,7 +377,7 @@ ${referencingAssets
404
377
  await Promise.all(
405
378
  assetsWithInfo.map(async asset => {
406
379
  await computeNewContent(asset);
407
- const newName = hashReplace(asset.name, hash =>
380
+ const newName = asset.name.replace(hashRegExp, hash =>
408
381
  hashToNewHash.get(hash)
409
382
  );
410
383
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.76.0",
3
+ "version": "5.76.1",
4
4
  "author": "Tobias Koppers @sokra",
5
5
  "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
6
6
  "license": "MIT",