webpack 5.58.1 → 5.58.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.

Potentially problematic release.


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

@@ -416,10 +416,10 @@ const byLocation = compareSelect(err => err.loc, compareLocations);
416
416
 
417
417
  const compareErrors = concatComparators(byModule, byLocation, byMessage);
418
418
 
419
- /** @type {WeakMap<Dependency, Module & { restoreFromUnsafeCache: Function }>} */
419
+ /** @type {WeakMap<Dependency, Module & { restoreFromUnsafeCache: Function } | null>} */
420
420
  const unsafeCacheDependencies = new WeakMap();
421
421
 
422
- /** @type {WeakMap<Module, object>} */
422
+ /** @type {WeakMap<Module & { restoreFromUnsafeCache: Function }, object>} */
423
423
  const unsafeCacheData = new WeakMap();
424
424
 
425
425
  class Compilation {
@@ -1023,8 +1023,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1023
1023
  this.usedModuleIds = null;
1024
1024
  /** @type {boolean} */
1025
1025
  this.needAdditionalPass = false;
1026
- /** @type {Set<Module>} */
1027
- this._restoredUnsafeCacheEntries = new Set();
1026
+ /** @type {Set<Module & { restoreFromUnsafeCache: Function }>} */
1027
+ this._restoredUnsafeCacheModuleEntries = new Set();
1028
+ /** @type {Map<string, Module & { restoreFromUnsafeCache: Function }>} */
1029
+ this._restoredUnsafeCacheEntries = new Map();
1028
1030
  /** @type {WeakSet<Module>} */
1029
1031
  this.builtModules = new WeakSet();
1030
1032
  /** @type {WeakSet<Module>} */
@@ -1424,9 +1426,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1424
1426
  * @returns {void}
1425
1427
  */
1426
1428
  _processModuleDependencies(module, callback) {
1427
- /**
1428
- * @type {Array<{factory: ModuleFactory, dependencies: Dependency[], originModule: Module|null}>}
1429
- */
1429
+ /** @type {Array<{factory: ModuleFactory, dependencies: Dependency[], originModule: Module|null}>} */
1430
1430
  const sortedDependencies = [];
1431
1431
 
1432
1432
  /** @type {DependenciesBlock} */
@@ -1447,7 +1447,46 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1447
1447
  /** @type {Dependency[]} */
1448
1448
  let listCacheValue;
1449
1449
 
1450
- const unsafeRestoredModules = new Set();
1450
+ let inProgressSorting = 1;
1451
+ let inProgressTransitive = 1;
1452
+
1453
+ const onDependenciesSorted = err => {
1454
+ if (err) return callback(err);
1455
+
1456
+ // early exit without changing parallelism back and forth
1457
+ if (sortedDependencies.length === 0 && inProgressTransitive === 1) {
1458
+ return callback();
1459
+ }
1460
+
1461
+ // This is nested so we need to allow one additional task
1462
+ this.processDependenciesQueue.increaseParallelism();
1463
+
1464
+ for (const item of sortedDependencies) {
1465
+ inProgressTransitive++;
1466
+ this.handleModuleCreation(item, err => {
1467
+ // In V8, the Error objects keep a reference to the functions on the stack. These warnings &
1468
+ // errors are created inside closures that keep a reference to the Compilation, so errors are
1469
+ // leaking the Compilation object.
1470
+ if (err && this.bail) {
1471
+ if (inProgressTransitive <= 0) return;
1472
+ inProgressTransitive = -1;
1473
+ // eslint-disable-next-line no-self-assign
1474
+ err.stack = err.stack;
1475
+ onTransitiveTasksFinished(err);
1476
+ return;
1477
+ }
1478
+ if (--inProgressTransitive === 0) onTransitiveTasksFinished();
1479
+ });
1480
+ }
1481
+ if (--inProgressTransitive === 0) onTransitiveTasksFinished();
1482
+ };
1483
+
1484
+ const onTransitiveTasksFinished = err => {
1485
+ if (err) return callback(err);
1486
+ this.processDependenciesQueue.decreaseParallelism();
1487
+
1488
+ return callback();
1489
+ };
1451
1490
 
1452
1491
  /**
1453
1492
  * @param {Dependency} dep dependency
@@ -1458,34 +1497,111 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1458
1497
  this.moduleGraph.setParents(dep, currentBlock, module, index);
1459
1498
  if (this._unsafeCache) {
1460
1499
  try {
1461
- const cachedModule = unsafeCacheDependencies.get(dep);
1462
- if (cachedModule === null) return;
1463
- if (cachedModule !== undefined) {
1464
- if (!this._restoredUnsafeCacheEntries.has(cachedModule)) {
1465
- const data = unsafeCacheData.get(cachedModule);
1466
- cachedModule.restoreFromUnsafeCache(
1467
- data,
1468
- this.params.normalModuleFactory,
1469
- this.params
1500
+ const unsafeCachedModule = unsafeCacheDependencies.get(dep);
1501
+ if (unsafeCachedModule === null) return;
1502
+ if (unsafeCachedModule !== undefined) {
1503
+ if (
1504
+ this._restoredUnsafeCacheModuleEntries.has(unsafeCachedModule)
1505
+ ) {
1506
+ this._handleExistingModuleFromUnsafeCache(
1507
+ module,
1508
+ dep,
1509
+ unsafeCachedModule
1470
1510
  );
1471
- this._restoredUnsafeCacheEntries.add(cachedModule);
1472
- if (!this.modules.has(cachedModule)) {
1473
- this._handleNewModuleFromUnsafeCache(module, dep, cachedModule);
1474
- unsafeRestoredModules.add(cachedModule);
1511
+ return;
1512
+ }
1513
+ const identifier = unsafeCachedModule.identifier();
1514
+ const cachedModule =
1515
+ this._restoredUnsafeCacheEntries.get(identifier);
1516
+ if (cachedModule !== undefined) {
1517
+ // update unsafe cache to new module
1518
+ unsafeCacheDependencies.set(dep, cachedModule);
1519
+ this._handleExistingModuleFromUnsafeCache(
1520
+ module,
1521
+ dep,
1522
+ cachedModule
1523
+ );
1524
+ return;
1525
+ }
1526
+ inProgressSorting++;
1527
+ this._modulesCache.get(identifier, null, (err, cachedModule) => {
1528
+ if (err) {
1529
+ if (inProgressSorting <= 0) return;
1530
+ inProgressSorting = -1;
1531
+ onDependenciesSorted(err);
1475
1532
  return;
1476
1533
  }
1477
- }
1478
- this._handleExistingModuleFromUnsafeCache(
1479
- module,
1480
- dep,
1481
- cachedModule
1482
- );
1534
+ try {
1535
+ if (!this._restoredUnsafeCacheEntries.has(identifier)) {
1536
+ const data = unsafeCacheData.get(cachedModule);
1537
+ if (data === undefined) {
1538
+ processDependencyForResolving(dep);
1539
+ if (--inProgressSorting === 0) onDependenciesSorted();
1540
+ return;
1541
+ }
1542
+ if (cachedModule !== unsafeCachedModule) {
1543
+ unsafeCacheDependencies.set(dep, cachedModule);
1544
+ }
1545
+ cachedModule.restoreFromUnsafeCache(
1546
+ data,
1547
+ this.params.normalModuleFactory,
1548
+ this.params
1549
+ );
1550
+ this._restoredUnsafeCacheEntries.set(
1551
+ identifier,
1552
+ cachedModule
1553
+ );
1554
+ this._restoredUnsafeCacheModuleEntries.add(cachedModule);
1555
+ if (!this.modules.has(cachedModule)) {
1556
+ inProgressTransitive++;
1557
+ this._handleNewModuleFromUnsafeCache(
1558
+ module,
1559
+ dep,
1560
+ cachedModule,
1561
+ err => {
1562
+ if (err) {
1563
+ if (inProgressTransitive <= 0) return;
1564
+ inProgressTransitive = -1;
1565
+ onTransitiveTasksFinished(err);
1566
+ }
1567
+ if (--inProgressTransitive === 0)
1568
+ return onTransitiveTasksFinished();
1569
+ }
1570
+ );
1571
+ if (--inProgressSorting === 0) onDependenciesSorted();
1572
+ return;
1573
+ }
1574
+ }
1575
+ if (unsafeCachedModule !== cachedModule) {
1576
+ unsafeCacheDependencies.set(dep, cachedModule);
1577
+ }
1578
+ this._handleExistingModuleFromUnsafeCache(
1579
+ module,
1580
+ dep,
1581
+ cachedModule
1582
+ ); // a3
1583
+ } catch (err) {
1584
+ if (inProgressSorting <= 0) return;
1585
+ inProgressSorting = -1;
1586
+ onDependenciesSorted(err);
1587
+ return;
1588
+ }
1589
+ if (--inProgressSorting === 0) onDependenciesSorted();
1590
+ });
1483
1591
  return;
1484
1592
  }
1485
1593
  } catch (e) {
1486
1594
  console.error(e);
1487
1595
  }
1488
1596
  }
1597
+ processDependencyForResolving(dep);
1598
+ };
1599
+
1600
+ /**
1601
+ * @param {Dependency} dep dependency
1602
+ * @returns {void}
1603
+ */
1604
+ const processDependencyForResolving = dep => {
1489
1605
  const resourceIdent = dep.getResourceIdentifier();
1490
1606
  if (resourceIdent !== undefined && resourceIdent !== null) {
1491
1607
  const category = dep.category;
@@ -1570,68 +1686,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1570
1686
  return callback(e);
1571
1687
  }
1572
1688
 
1573
- if (sortedDependencies.length === 0 && unsafeRestoredModules.size === 0) {
1574
- callback();
1575
- return;
1576
- }
1577
-
1578
- // This is nested so we need to allow one additional task
1579
- this.processDependenciesQueue.increaseParallelism();
1580
-
1581
- const processSortedDependency = (item, callback) => {
1582
- this.handleModuleCreation(item, err => {
1583
- // In V8, the Error objects keep a reference to the functions on the stack. These warnings &
1584
- // errors are created inside closures that keep a reference to the Compilation, so errors are
1585
- // leaking the Compilation object.
1586
- if (err && this.bail) {
1587
- // eslint-disable-next-line no-self-assign
1588
- err.stack = err.stack;
1589
- return callback(err);
1590
- }
1591
- callback();
1592
- });
1593
- };
1594
-
1595
- const processUnsafeRestoredModule = (item, callback) => {
1596
- this._handleModuleBuildAndDependencies(module, item, true, callback);
1597
- };
1598
-
1599
- const finalCallback = err => {
1600
- this.processDependenciesQueue.decreaseParallelism();
1601
-
1602
- return callback(err);
1603
- };
1604
-
1605
- if (sortedDependencies.length === 0) {
1606
- asyncLib.forEach(
1607
- unsafeRestoredModules,
1608
- processUnsafeRestoredModule,
1609
- finalCallback
1610
- );
1611
- } else if (unsafeRestoredModules.size === 0) {
1612
- asyncLib.forEach(
1613
- sortedDependencies,
1614
- processSortedDependency,
1615
- finalCallback
1616
- );
1617
- } else {
1618
- asyncLib.parallel(
1619
- [
1620
- cb =>
1621
- asyncLib.forEach(
1622
- unsafeRestoredModules,
1623
- processUnsafeRestoredModule,
1624
- cb
1625
- ),
1626
- cb =>
1627
- asyncLib.forEach(sortedDependencies, processSortedDependency, cb)
1628
- ],
1629
- finalCallback
1630
- );
1631
- }
1689
+ if (--inProgressSorting === 0) onDependenciesSorted();
1632
1690
  }
1633
1691
 
1634
- _handleNewModuleFromUnsafeCache(originModule, dependency, module) {
1692
+ _handleNewModuleFromUnsafeCache(originModule, dependency, module, callback) {
1635
1693
  const moduleGraph = this.moduleGraph;
1636
1694
 
1637
1695
  moduleGraph.setResolvedModule(originModule, dependency, module);
@@ -1644,6 +1702,13 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1644
1702
  this._modules.set(module.identifier(), module);
1645
1703
  this.modules.add(module);
1646
1704
  ModuleGraph.setModuleGraphForModule(module, this.moduleGraph);
1705
+
1706
+ this._handleModuleBuildAndDependencies(
1707
+ originModule,
1708
+ module,
1709
+ true,
1710
+ callback
1711
+ );
1647
1712
  }
1648
1713
 
1649
1714
  _handleExistingModuleFromUnsafeCache(originModule, dependency, module) {
@@ -1747,20 +1812,24 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1747
1812
  /** @type {any} */ (module).restoreFromUnsafeCache &&
1748
1813
  this._unsafeCachePredicate(module)
1749
1814
  ) {
1815
+ const unsafeCacheableModule =
1816
+ /** @type {Module & { restoreFromUnsafeCache: Function }} */ (
1817
+ module
1818
+ );
1750
1819
  for (let i = 0; i < dependencies.length; i++) {
1751
1820
  const dependency = dependencies[i];
1752
1821
  moduleGraph.setResolvedModule(
1753
1822
  connectOrigin ? originModule : null,
1754
1823
  dependency,
1755
- module
1756
- );
1757
- unsafeCacheDependencies.set(
1758
- dependency,
1759
- /** @type {any} */ (module)
1824
+ unsafeCacheableModule
1760
1825
  );
1826
+ unsafeCacheDependencies.set(dependency, unsafeCacheableModule);
1761
1827
  }
1762
- if (!unsafeCacheData.has(module)) {
1763
- unsafeCacheData.set(module, module.getUnsafeCacheData());
1828
+ if (!unsafeCacheData.has(unsafeCacheableModule)) {
1829
+ unsafeCacheData.set(
1830
+ unsafeCacheableModule,
1831
+ unsafeCacheableModule.getUnsafeCacheData()
1832
+ );
1764
1833
  }
1765
1834
  } else {
1766
1835
  applyFactoryResultDependencies();
@@ -206,17 +206,17 @@ class Snapshot {
206
206
  this._flags = 0;
207
207
  /** @type {number | undefined} */
208
208
  this.startTime = undefined;
209
- /** @type {Map<string, FileSystemInfoEntry> | undefined} */
209
+ /** @type {Map<string, FileSystemInfoEntry | null> | undefined} */
210
210
  this.fileTimestamps = undefined;
211
- /** @type {Map<string, string> | undefined} */
211
+ /** @type {Map<string, string | null> | undefined} */
212
212
  this.fileHashes = undefined;
213
- /** @type {Map<string, TimestampAndHash | string> | undefined} */
213
+ /** @type {Map<string, TimestampAndHash | string | null> | undefined} */
214
214
  this.fileTshs = undefined;
215
- /** @type {Map<string, ResolvedContextFileSystemInfoEntry> | undefined} */
215
+ /** @type {Map<string, ResolvedContextFileSystemInfoEntry | null> | undefined} */
216
216
  this.contextTimestamps = undefined;
217
- /** @type {Map<string, string> | undefined} */
217
+ /** @type {Map<string, string | null> | undefined} */
218
218
  this.contextHashes = undefined;
219
- /** @type {Map<string, ResolvedContextTimestampAndHash> | undefined} */
219
+ /** @type {Map<string, ResolvedContextTimestampAndHash | null> | undefined} */
220
220
  this.contextTshs = undefined;
221
221
  /** @type {Map<string, boolean> | undefined} */
222
222
  this.missingExistence = undefined;
@@ -823,11 +823,10 @@ const getManagedItem = (managedPath, path) => {
823
823
 
824
824
  /**
825
825
  * @template {ContextFileSystemInfoEntry | ContextTimestampAndHash} T
826
- * @param {T | "ignore"} entry entry
826
+ * @param {T} entry entry
827
827
  * @returns {T["resolved"] | undefined} the resolved entry
828
828
  */
829
829
  const getResolvedTimestamp = entry => {
830
- if (entry === "ignore") return undefined;
831
830
  if (entry === null) return null;
832
831
  if (entry.resolved !== undefined) return entry.resolved;
833
832
  return entry.symlinks === undefined ? entry : undefined;
@@ -1191,6 +1190,7 @@ class FileSystemInfo {
1191
1190
  getContextTimestamp(path, callback) {
1192
1191
  const cache = this._contextTimestamps.get(path);
1193
1192
  if (cache !== undefined) {
1193
+ if (cache === "ignore") return callback(null, "ignore");
1194
1194
  const resolved = getResolvedTimestamp(cache);
1195
1195
  if (resolved !== undefined) return callback(null, resolved);
1196
1196
  return this._resolveContextTimestamp(cache, callback);
@@ -1876,17 +1876,17 @@ class FileSystemInfo {
1876
1876
  * @returns {void}
1877
1877
  */
1878
1878
  createSnapshot(startTime, files, directories, missing, options, callback) {
1879
- /** @type {Map<string, FileSystemInfoEntry>} */
1879
+ /** @type {Map<string, FileSystemInfoEntry | null>} */
1880
1880
  const fileTimestamps = new Map();
1881
- /** @type {Map<string, string>} */
1881
+ /** @type {Map<string, string | null>} */
1882
1882
  const fileHashes = new Map();
1883
- /** @type {Map<string, TimestampAndHash | string>} */
1883
+ /** @type {Map<string, TimestampAndHash | string | null>} */
1884
1884
  const fileTshs = new Map();
1885
- /** @type {Map<string, FileSystemInfoEntry>} */
1885
+ /** @type {Map<string, FileSystemInfoEntry | null>} */
1886
1886
  const contextTimestamps = new Map();
1887
- /** @type {Map<string, string>} */
1887
+ /** @type {Map<string, string | null>} */
1888
1888
  const contextHashes = new Map();
1889
- /** @type {Map<string, TimestampAndHash | string>} */
1889
+ /** @type {Map<string, ResolvedContextTimestampAndHash | null>} */
1890
1890
  const contextTshs = new Map();
1891
1891
  /** @type {Map<string, boolean>} */
1892
1892
  const missingExistence = new Map();
@@ -2080,6 +2080,7 @@ class FileSystemInfo {
2080
2080
  this._contextTshsOptimization.optimize(snapshot, capturedDirectories);
2081
2081
  for (const path of capturedDirectories) {
2082
2082
  const cache = this._contextTshs.get(path);
2083
+ /** @type {ResolvedContextTimestampAndHash} */
2083
2084
  let resolved;
2084
2085
  if (
2085
2086
  cache !== undefined &&
@@ -2088,6 +2089,11 @@ class FileSystemInfo {
2088
2089
  contextTshs.set(path, resolved);
2089
2090
  } else {
2090
2091
  jobs++;
2092
+ /**
2093
+ * @param {Error=} err error
2094
+ * @param {ResolvedContextTimestampAndHash=} entry entry
2095
+ * @returns {void}
2096
+ */
2091
2097
  const callback = (err, entry) => {
2092
2098
  if (err) {
2093
2099
  if (this.logger) {
@@ -2152,14 +2158,20 @@ class FileSystemInfo {
2152
2158
  );
2153
2159
  for (const path of capturedDirectories) {
2154
2160
  const cache = this._contextTimestamps.get(path);
2161
+ if (cache === "ignore") continue;
2155
2162
  let resolved;
2156
2163
  if (
2157
2164
  cache !== undefined &&
2158
2165
  (resolved = getResolvedTimestamp(cache)) !== undefined
2159
2166
  ) {
2160
2167
  contextTimestamps.set(path, resolved);
2161
- } else if (cache !== "ignore") {
2168
+ } else {
2162
2169
  jobs++;
2170
+ /**
2171
+ * @param {Error=} err error
2172
+ * @param {ResolvedContextFileSystemInfoEntry=} entry entry
2173
+ * @returns {void}
2174
+ */
2163
2175
  const callback = (err, entry) => {
2164
2176
  if (err) {
2165
2177
  if (this.logger) {
@@ -2572,14 +2584,14 @@ class FileSystemInfo {
2572
2584
  const cache = this._fileTimestamps.get(path);
2573
2585
  if (cache !== undefined) {
2574
2586
  if (cache === "ignore" || !checkFile(path, cache, tsh, false)) {
2575
- processFileHashSnapshot(path, tsh.hash);
2587
+ processFileHashSnapshot(path, tsh && tsh.hash);
2576
2588
  }
2577
2589
  } else {
2578
2590
  jobs++;
2579
2591
  this.fileTimestampQueue.add(path, (err, entry) => {
2580
2592
  if (err) return invalidWithError(path, err);
2581
2593
  if (!checkFile(path, entry, tsh, false)) {
2582
- processFileHashSnapshot(path, tsh.hash);
2594
+ processFileHashSnapshot(path, tsh && tsh.hash);
2583
2595
  }
2584
2596
  jobDone();
2585
2597
  });
@@ -2592,6 +2604,7 @@ class FileSystemInfo {
2592
2604
  this._statTestedEntries += contextTimestamps.size;
2593
2605
  for (const [path, ts] of contextTimestamps) {
2594
2606
  const cache = this._contextTimestamps.get(path);
2607
+ if (cache === "ignore") continue;
2595
2608
  let resolved;
2596
2609
  if (
2597
2610
  cache !== undefined &&
@@ -2601,8 +2614,13 @@ class FileSystemInfo {
2601
2614
  invalid();
2602
2615
  return;
2603
2616
  }
2604
- } else if (cache !== "ignore") {
2617
+ } else {
2605
2618
  jobs++;
2619
+ /**
2620
+ * @param {Error=} err error
2621
+ * @param {ResolvedContextFileSystemInfoEntry=} entry entry
2622
+ * @returns {void}
2623
+ */
2606
2624
  const callback = (err, entry) => {
2607
2625
  if (err) return invalidWithError(path, err);
2608
2626
  if (!checkContext(path, entry, ts)) {
@@ -2662,27 +2680,33 @@ class FileSystemInfo {
2662
2680
  processContextHashSnapshot(path, tsh);
2663
2681
  } else {
2664
2682
  const cache = this._contextTimestamps.get(path);
2683
+ if (cache === "ignore") continue;
2665
2684
  let resolved;
2666
2685
  if (
2667
2686
  cache !== undefined &&
2668
2687
  (resolved = getResolvedTimestamp(cache)) !== undefined
2669
2688
  ) {
2670
2689
  if (!checkContext(path, resolved, tsh, false)) {
2671
- processContextHashSnapshot(path, tsh.hash);
2690
+ processContextHashSnapshot(path, tsh && tsh.hash);
2672
2691
  }
2673
- } else if (cache !== "ignore") {
2692
+ } else {
2674
2693
  jobs++;
2694
+ /**
2695
+ * @param {Error=} err error
2696
+ * @param {ResolvedContextFileSystemInfoEntry=} entry entry
2697
+ * @returns {void}
2698
+ */
2675
2699
  const callback = (err, entry) => {
2676
2700
  if (err) return invalidWithError(path, err);
2677
2701
  if (!checkContext(path, entry, tsh, false)) {
2678
- processContextHashSnapshot(path, tsh.hash);
2702
+ processContextHashSnapshot(path, tsh && tsh.hash);
2679
2703
  }
2680
2704
  jobDone();
2681
2705
  };
2682
2706
  if (cache !== undefined) {
2683
- this._resolveContextTsh(cache, callback);
2707
+ this._resolveContextTimestamp(cache, callback);
2684
2708
  } else {
2685
- this.getContextTsh(path, callback);
2709
+ this.getContextTimestamp(path, callback);
2686
2710
  }
2687
2711
  }
2688
2712
  }
@@ -3032,6 +3056,11 @@ class FileSystemInfo {
3032
3056
  );
3033
3057
  }
3034
3058
 
3059
+ /**
3060
+ * @param {ContextFileSystemInfoEntry} entry entry
3061
+ * @param {function(Error=, ResolvedContextFileSystemInfoEntry=): void} callback callback
3062
+ * @returns {void}
3063
+ */
3035
3064
  _resolveContextTimestamp(entry, callback) {
3036
3065
  const hashes = [];
3037
3066
  let safeTime = 0;
@@ -3135,6 +3164,11 @@ class FileSystemInfo {
3135
3164
  );
3136
3165
  }
3137
3166
 
3167
+ /**
3168
+ * @param {ContextHash} entry context hash
3169
+ * @param {function(Error=, string=): void} callback callback
3170
+ * @returns {void}
3171
+ */
3138
3172
  _resolveContextHash(entry, callback) {
3139
3173
  const hashes = [];
3140
3174
  processAsyncTree(
@@ -3286,6 +3320,11 @@ class FileSystemInfo {
3286
3320
  }
3287
3321
  }
3288
3322
 
3323
+ /**
3324
+ * @param {ContextTimestampAndHash} entry entry
3325
+ * @param {function(Error=, ResolvedContextTimestampAndHash=): void} callback callback
3326
+ * @returns {void}
3327
+ */
3289
3328
  _resolveContextTsh(entry, callback) {
3290
3329
  const hashes = [];
3291
3330
  const tsHashes = [];
@@ -774,9 +774,13 @@ module.exports = class SplitChunksPlugin {
774
774
  const chunkIndexMap = new Map();
775
775
  const ZERO = BigInt("0");
776
776
  const ONE = BigInt("1");
777
- let index = ONE;
777
+ const START = ONE << BigInt("31");
778
+ let index = START;
778
779
  for (const chunk of chunks) {
779
- chunkIndexMap.set(chunk, index);
780
+ chunkIndexMap.set(
781
+ chunk,
782
+ index | BigInt((Math.random() * 0x7fffffff) | 0)
783
+ );
780
784
  index = index << ONE;
781
785
  }
782
786
  /**
@@ -793,7 +797,8 @@ module.exports = class SplitChunksPlugin {
793
797
  let key =
794
798
  chunkIndexMap.get(first) | chunkIndexMap.get(result.value);
795
799
  while (!(result = iterator.next()).done) {
796
- key = key | chunkIndexMap.get(result.value);
800
+ const raw = chunkIndexMap.get(result.value);
801
+ key = key ^ raw;
797
802
  }
798
803
  return key;
799
804
  };
@@ -16,9 +16,7 @@ class Serializer {
16
16
  let current = obj;
17
17
  for (const middleware of this.serializeMiddlewares) {
18
18
  if (current && typeof current.then === "function") {
19
- current = current.then(
20
- data => data && middleware.serialize(data, context)
21
- );
19
+ current = current.then(data => data && middleware.serialize(data, ctx));
22
20
  } else if (current) {
23
21
  try {
24
22
  current = middleware.serialize(current, ctx);
@@ -36,7 +34,7 @@ class Serializer {
36
34
  let current = value;
37
35
  for (const middleware of this.deserializeMiddlewares) {
38
36
  if (current && typeof current.then === "function") {
39
- current = current.then(data => middleware.deserialize(data, context));
37
+ current = current.then(data => middleware.deserialize(data, ctx));
40
38
  } else {
41
39
  current = middleware.deserialize(current, ctx);
42
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.58.1",
3
+ "version": "5.58.2",
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",
package/types.d.ts CHANGED
@@ -10448,12 +10448,12 @@ declare class SizeOnlySource extends Source {
10448
10448
  }
10449
10449
  declare abstract class Snapshot {
10450
10450
  startTime?: number;
10451
- fileTimestamps?: Map<string, FileSystemInfoEntry>;
10452
- fileHashes?: Map<string, string>;
10453
- fileTshs?: Map<string, string | TimestampAndHash>;
10454
- contextTimestamps?: Map<string, ResolvedContextFileSystemInfoEntry>;
10455
- contextHashes?: Map<string, string>;
10456
- contextTshs?: Map<string, ResolvedContextTimestampAndHash>;
10451
+ fileTimestamps?: Map<string, null | FileSystemInfoEntry>;
10452
+ fileHashes?: Map<string, null | string>;
10453
+ fileTshs?: Map<string, null | string | TimestampAndHash>;
10454
+ contextTimestamps?: Map<string, null | ResolvedContextFileSystemInfoEntry>;
10455
+ contextHashes?: Map<string, null | string>;
10456
+ contextTshs?: Map<string, null | ResolvedContextTimestampAndHash>;
10457
10457
  missingExistence?: Map<string, boolean>;
10458
10458
  managedItemInfo?: Map<string, string>;
10459
10459
  managedFiles?: Set<string>;