webpack 5.57.1 → 5.59.0
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.
- package/lib/AsyncDependenciesBlock.js +0 -2
- package/lib/ChunkGraph.js +0 -26
- package/lib/Compilation.js +222 -115
- package/lib/Compiler.js +2 -2
- package/lib/DefinePlugin.js +1 -1
- package/lib/DependenciesBlock.js +9 -0
- package/lib/Dependency.js +2 -0
- package/lib/FileSystemInfo.js +112 -30
- package/lib/Module.js +4 -0
- package/lib/ModuleGraph.js +11 -17
- package/lib/NormalModule.js +64 -27
- package/lib/NormalModuleFactory.js +57 -55
- package/lib/RuntimeTemplate.js +1 -1
- package/lib/WebpackOptionsApply.js +0 -2
- package/lib/buildChunkGraph.js +157 -100
- package/lib/cache/AddManagedPathsPlugin.js +2 -2
- package/lib/cache/PackFileCacheStrategy.js +2 -2
- package/lib/config/defaults.js +65 -43
- package/lib/config/normalization.js +6 -1
- package/lib/logging/Logger.js +1 -0
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/optimize/ConcatenatedModule.js +1 -1
- package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -0
- package/lib/optimize/SplitChunksPlugin.js +57 -4
- package/lib/schemes/FileUriPlugin.js +9 -0
- package/lib/schemes/HttpUriPlugin.js +107 -31
- package/lib/serialization/Serializer.js +2 -4
- package/lib/util/fs.js +2 -0
- package/lib/util/propertyAccess.js +2 -2
- package/package.json +1 -1
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +258 -55
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.json +28 -0
- package/types.d.ts +118 -91
package/lib/ChunkGraph.js
CHANGED
@@ -235,16 +235,6 @@ class ChunkGraph {
|
|
235
235
|
this._hashFunction = hashFunction;
|
236
236
|
|
237
237
|
this._getGraphRoots = this._getGraphRoots.bind(this);
|
238
|
-
|
239
|
-
// Caching
|
240
|
-
this._cacheChunkGraphModuleKey1 = undefined;
|
241
|
-
this._cacheChunkGraphModuleValue1 = undefined;
|
242
|
-
this._cacheChunkGraphModuleKey2 = undefined;
|
243
|
-
this._cacheChunkGraphModuleValue2 = undefined;
|
244
|
-
this._cacheChunkGraphChunkKey1 = undefined;
|
245
|
-
this._cacheChunkGraphChunkValue1 = undefined;
|
246
|
-
this._cacheChunkGraphChunkKey2 = undefined;
|
247
|
-
this._cacheChunkGraphChunkValue2 = undefined;
|
248
238
|
}
|
249
239
|
|
250
240
|
/**
|
@@ -253,19 +243,11 @@ class ChunkGraph {
|
|
253
243
|
* @returns {ChunkGraphModule} internal module
|
254
244
|
*/
|
255
245
|
_getChunkGraphModule(module) {
|
256
|
-
if (this._cacheChunkGraphModuleKey1 === module)
|
257
|
-
return this._cacheChunkGraphModuleValue1;
|
258
|
-
if (this._cacheChunkGraphModuleKey2 === module)
|
259
|
-
return this._cacheChunkGraphModuleValue2;
|
260
246
|
let cgm = this._modules.get(module);
|
261
247
|
if (cgm === undefined) {
|
262
248
|
cgm = new ChunkGraphModule();
|
263
249
|
this._modules.set(module, cgm);
|
264
250
|
}
|
265
|
-
this._cacheChunkGraphModuleKey2 = this._cacheChunkGraphModuleKey1;
|
266
|
-
this._cacheChunkGraphModuleValue2 = this._cacheChunkGraphModuleValue1;
|
267
|
-
this._cacheChunkGraphModuleKey1 = module;
|
268
|
-
this._cacheChunkGraphModuleValue1 = cgm;
|
269
251
|
return cgm;
|
270
252
|
}
|
271
253
|
|
@@ -275,19 +257,11 @@ class ChunkGraph {
|
|
275
257
|
* @returns {ChunkGraphChunk} internal chunk
|
276
258
|
*/
|
277
259
|
_getChunkGraphChunk(chunk) {
|
278
|
-
if (this._cacheChunkGraphChunkKey1 === chunk)
|
279
|
-
return this._cacheChunkGraphChunkValue1;
|
280
|
-
if (this._cacheChunkGraphChunkKey2 === chunk)
|
281
|
-
return this._cacheChunkGraphChunkValue2;
|
282
260
|
let cgc = this._chunks.get(chunk);
|
283
261
|
if (cgc === undefined) {
|
284
262
|
cgc = new ChunkGraphChunk();
|
285
263
|
this._chunks.set(chunk, cgc);
|
286
264
|
}
|
287
|
-
this._cacheChunkGraphChunkKey2 = this._cacheChunkGraphChunkKey1;
|
288
|
-
this._cacheChunkGraphChunkValue2 = this._cacheChunkGraphChunkValue1;
|
289
|
-
this._cacheChunkGraphChunkKey1 = chunk;
|
290
|
-
this._cacheChunkGraphChunkValue1 = cgc;
|
291
265
|
return cgc;
|
292
266
|
}
|
293
267
|
|
package/lib/Compilation.js
CHANGED
@@ -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.
|
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>} */
|
@@ -1405,8 +1407,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1405
1407
|
processModuleDependenciesNonRecursive(module) {
|
1406
1408
|
const processDependenciesBlock = block => {
|
1407
1409
|
if (block.dependencies) {
|
1410
|
+
let i = 0;
|
1408
1411
|
for (const dep of block.dependencies) {
|
1409
|
-
this.moduleGraph.setParents(dep, block, module);
|
1412
|
+
this.moduleGraph.setParents(dep, block, module, i++);
|
1410
1413
|
}
|
1411
1414
|
}
|
1412
1415
|
if (block.blocks) {
|
@@ -1423,9 +1426,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1423
1426
|
* @returns {void}
|
1424
1427
|
*/
|
1425
1428
|
_processModuleDependencies(module, callback) {
|
1426
|
-
/**
|
1427
|
-
* @type {Array<{factory: ModuleFactory, dependencies: Dependency[], originModule: Module|null}>}
|
1428
|
-
*/
|
1429
|
+
/** @type {Array<{factory: ModuleFactory, dependencies: Dependency[], originModule: Module|null}>} */
|
1429
1430
|
const sortedDependencies = [];
|
1430
1431
|
|
1431
1432
|
/** @type {DependenciesBlock} */
|
@@ -1446,44 +1447,161 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1446
1447
|
/** @type {Dependency[]} */
|
1447
1448
|
let listCacheValue;
|
1448
1449
|
|
1449
|
-
|
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
|
+
};
|
1450
1490
|
|
1451
1491
|
/**
|
1452
1492
|
* @param {Dependency} dep dependency
|
1493
|
+
* @param {number} index index in block
|
1453
1494
|
* @returns {void}
|
1454
1495
|
*/
|
1455
|
-
const processDependency = dep => {
|
1456
|
-
this.moduleGraph.setParents(dep, currentBlock, module);
|
1496
|
+
const processDependency = (dep, index) => {
|
1497
|
+
this.moduleGraph.setParents(dep, currentBlock, module, index);
|
1457
1498
|
if (this._unsafeCache) {
|
1458
1499
|
try {
|
1459
|
-
const
|
1460
|
-
if (
|
1461
|
-
if (
|
1462
|
-
if (
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
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
|
1468
1510
|
);
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
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);
|
1473
1532
|
return;
|
1474
1533
|
}
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
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
|
+
});
|
1481
1591
|
return;
|
1482
1592
|
}
|
1483
1593
|
} catch (e) {
|
1484
1594
|
console.error(e);
|
1485
1595
|
}
|
1486
1596
|
}
|
1597
|
+
processDependencyForResolving(dep);
|
1598
|
+
};
|
1599
|
+
|
1600
|
+
/**
|
1601
|
+
* @param {Dependency} dep dependency
|
1602
|
+
* @returns {void}
|
1603
|
+
*/
|
1604
|
+
const processDependencyForResolving = dep => {
|
1487
1605
|
const resourceIdent = dep.getResourceIdentifier();
|
1488
1606
|
if (resourceIdent !== undefined && resourceIdent !== null) {
|
1489
1607
|
const category = dep.category;
|
@@ -1557,7 +1675,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1557
1675
|
const block = queue.pop();
|
1558
1676
|
if (block.dependencies) {
|
1559
1677
|
currentBlock = block;
|
1560
|
-
|
1678
|
+
let i = 0;
|
1679
|
+
for (const dep of block.dependencies) processDependency(dep, i++);
|
1561
1680
|
}
|
1562
1681
|
if (block.blocks) {
|
1563
1682
|
for (const b of block.blocks) queue.push(b);
|
@@ -1567,68 +1686,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1567
1686
|
return callback(e);
|
1568
1687
|
}
|
1569
1688
|
|
1570
|
-
if (
|
1571
|
-
callback();
|
1572
|
-
return;
|
1573
|
-
}
|
1574
|
-
|
1575
|
-
// This is nested so we need to allow one additional task
|
1576
|
-
this.processDependenciesQueue.increaseParallelism();
|
1577
|
-
|
1578
|
-
const processSortedDependency = (item, callback) => {
|
1579
|
-
this.handleModuleCreation(item, err => {
|
1580
|
-
// In V8, the Error objects keep a reference to the functions on the stack. These warnings &
|
1581
|
-
// errors are created inside closures that keep a reference to the Compilation, so errors are
|
1582
|
-
// leaking the Compilation object.
|
1583
|
-
if (err && this.bail) {
|
1584
|
-
// eslint-disable-next-line no-self-assign
|
1585
|
-
err.stack = err.stack;
|
1586
|
-
return callback(err);
|
1587
|
-
}
|
1588
|
-
callback();
|
1589
|
-
});
|
1590
|
-
};
|
1591
|
-
|
1592
|
-
const processUnsafeRestoredModule = (item, callback) => {
|
1593
|
-
this._handleModuleBuildAndDependencies(module, item, true, callback);
|
1594
|
-
};
|
1595
|
-
|
1596
|
-
const finalCallback = err => {
|
1597
|
-
this.processDependenciesQueue.decreaseParallelism();
|
1598
|
-
|
1599
|
-
return callback(err);
|
1600
|
-
};
|
1601
|
-
|
1602
|
-
if (sortedDependencies.length === 0) {
|
1603
|
-
asyncLib.forEach(
|
1604
|
-
unsafeRestoredModules,
|
1605
|
-
processUnsafeRestoredModule,
|
1606
|
-
finalCallback
|
1607
|
-
);
|
1608
|
-
} else if (unsafeRestoredModules.size === 0) {
|
1609
|
-
asyncLib.forEach(
|
1610
|
-
sortedDependencies,
|
1611
|
-
processSortedDependency,
|
1612
|
-
finalCallback
|
1613
|
-
);
|
1614
|
-
} else {
|
1615
|
-
asyncLib.parallel(
|
1616
|
-
[
|
1617
|
-
cb =>
|
1618
|
-
asyncLib.forEach(
|
1619
|
-
unsafeRestoredModules,
|
1620
|
-
processUnsafeRestoredModule,
|
1621
|
-
cb
|
1622
|
-
),
|
1623
|
-
cb =>
|
1624
|
-
asyncLib.forEach(sortedDependencies, processSortedDependency, cb)
|
1625
|
-
],
|
1626
|
-
finalCallback
|
1627
|
-
);
|
1628
|
-
}
|
1689
|
+
if (--inProgressSorting === 0) onDependenciesSorted();
|
1629
1690
|
}
|
1630
1691
|
|
1631
|
-
_handleNewModuleFromUnsafeCache(originModule, dependency, module) {
|
1692
|
+
_handleNewModuleFromUnsafeCache(originModule, dependency, module, callback) {
|
1632
1693
|
const moduleGraph = this.moduleGraph;
|
1633
1694
|
|
1634
1695
|
moduleGraph.setResolvedModule(originModule, dependency, module);
|
@@ -1641,6 +1702,13 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1641
1702
|
this._modules.set(module.identifier(), module);
|
1642
1703
|
this.modules.add(module);
|
1643
1704
|
ModuleGraph.setModuleGraphForModule(module, this.moduleGraph);
|
1705
|
+
|
1706
|
+
this._handleModuleBuildAndDependencies(
|
1707
|
+
originModule,
|
1708
|
+
module,
|
1709
|
+
true,
|
1710
|
+
callback
|
1711
|
+
);
|
1644
1712
|
}
|
1645
1713
|
|
1646
1714
|
_handleExistingModuleFromUnsafeCache(originModule, dependency, module) {
|
@@ -1744,20 +1812,24 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1744
1812
|
/** @type {any} */ (module).restoreFromUnsafeCache &&
|
1745
1813
|
this._unsafeCachePredicate(module)
|
1746
1814
|
) {
|
1815
|
+
const unsafeCacheableModule =
|
1816
|
+
/** @type {Module & { restoreFromUnsafeCache: Function }} */ (
|
1817
|
+
module
|
1818
|
+
);
|
1747
1819
|
for (let i = 0; i < dependencies.length; i++) {
|
1748
1820
|
const dependency = dependencies[i];
|
1749
1821
|
moduleGraph.setResolvedModule(
|
1750
1822
|
connectOrigin ? originModule : null,
|
1751
1823
|
dependency,
|
1752
|
-
|
1753
|
-
);
|
1754
|
-
unsafeCacheDependencies.set(
|
1755
|
-
dependency,
|
1756
|
-
/** @type {any} */ (module)
|
1824
|
+
unsafeCacheableModule
|
1757
1825
|
);
|
1826
|
+
unsafeCacheDependencies.set(dependency, unsafeCacheableModule);
|
1758
1827
|
}
|
1759
|
-
if (!unsafeCacheData.has(
|
1760
|
-
unsafeCacheData.set(
|
1828
|
+
if (!unsafeCacheData.has(unsafeCacheableModule)) {
|
1829
|
+
unsafeCacheData.set(
|
1830
|
+
unsafeCacheableModule,
|
1831
|
+
unsafeCacheableModule.getUnsafeCacheData()
|
1832
|
+
);
|
1761
1833
|
}
|
1762
1834
|
} else {
|
1763
1835
|
applyFactoryResultDependencies();
|
@@ -1811,7 +1883,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1811
1883
|
creatingModuleDuringBuildSet
|
1812
1884
|
);
|
1813
1885
|
}
|
1814
|
-
creatingModuleDuringBuildSet.add(
|
1886
|
+
creatingModuleDuringBuildSet.add(module);
|
1815
1887
|
|
1816
1888
|
// When building is blocked by another module
|
1817
1889
|
// search for a cycle, cancel the cycle by throwing
|
@@ -2334,7 +2406,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2334
2406
|
);
|
2335
2407
|
}
|
2336
2408
|
|
2337
|
-
|
2409
|
+
_computeAffectedModulesWithChunkGraph() {
|
2338
2410
|
const { moduleMemCaches } = this;
|
2339
2411
|
if (!moduleMemCaches) return;
|
2340
2412
|
const moduleMemCaches2 = (this.moduleMemCaches2 = new Map());
|
@@ -2739,13 +2811,14 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2739
2811
|
this.chunkGroups.push(entrypoint);
|
2740
2812
|
connectChunkGroupAndChunk(entrypoint, chunk);
|
2741
2813
|
|
2814
|
+
const entryModules = new Set();
|
2742
2815
|
for (const dep of [...this.globalEntry.dependencies, ...dependencies]) {
|
2743
2816
|
entrypoint.addOrigin(null, { name }, /** @type {any} */ (dep).request);
|
2744
2817
|
|
2745
2818
|
const module = this.moduleGraph.getModule(dep);
|
2746
2819
|
if (module) {
|
2747
2820
|
chunkGraph.connectChunkAndEntryModule(chunk, module, entrypoint);
|
2748
|
-
|
2821
|
+
entryModules.add(module);
|
2749
2822
|
const modulesList = chunkGraphInit.get(entrypoint);
|
2750
2823
|
if (modulesList === undefined) {
|
2751
2824
|
chunkGraphInit.set(entrypoint, [module]);
|
@@ -2755,6 +2828,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2755
2828
|
}
|
2756
2829
|
}
|
2757
2830
|
|
2831
|
+
this.assignDepths(entryModules);
|
2832
|
+
|
2758
2833
|
const mapAndSort = deps =>
|
2759
2834
|
deps
|
2760
2835
|
.map(dep => this.moduleGraph.getModule(dep))
|
@@ -2901,7 +2976,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
2901
2976
|
|
2902
2977
|
this.assignRuntimeIds();
|
2903
2978
|
|
2904
|
-
this.
|
2979
|
+
this.logger.time("compute affected modules with chunk graph");
|
2980
|
+
this._computeAffectedModulesWithChunkGraph();
|
2981
|
+
this.logger.timeEnd("compute affected modules with chunk graph");
|
2905
2982
|
|
2906
2983
|
this.sortItemsWithChunkIds();
|
2907
2984
|
|
@@ -3522,6 +3599,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3522
3599
|
}
|
3523
3600
|
|
3524
3601
|
/**
|
3602
|
+
* @deprecated
|
3525
3603
|
* @param {Module} module module to assign depth
|
3526
3604
|
* @returns {void}
|
3527
3605
|
*/
|
@@ -3555,6 +3633,38 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3555
3633
|
}
|
3556
3634
|
}
|
3557
3635
|
|
3636
|
+
/**
|
3637
|
+
* @param {Set<Module>} modules module to assign depth
|
3638
|
+
* @returns {void}
|
3639
|
+
*/
|
3640
|
+
assignDepths(modules) {
|
3641
|
+
const moduleGraph = this.moduleGraph;
|
3642
|
+
|
3643
|
+
/** @type {Set<Module | number>} */
|
3644
|
+
const queue = new Set(modules);
|
3645
|
+
queue.add(1);
|
3646
|
+
let depth = 0;
|
3647
|
+
|
3648
|
+
let i = 0;
|
3649
|
+
for (const module of queue) {
|
3650
|
+
i++;
|
3651
|
+
if (typeof module === "number") {
|
3652
|
+
depth = module;
|
3653
|
+
if (queue.size === i) return;
|
3654
|
+
queue.add(depth + 1);
|
3655
|
+
} else {
|
3656
|
+
moduleGraph.setDepth(module, depth);
|
3657
|
+
for (const { module: refModule } of moduleGraph.getOutgoingConnections(
|
3658
|
+
module
|
3659
|
+
)) {
|
3660
|
+
if (refModule) {
|
3661
|
+
queue.add(refModule);
|
3662
|
+
}
|
3663
|
+
}
|
3664
|
+
}
|
3665
|
+
}
|
3666
|
+
}
|
3667
|
+
|
3558
3668
|
/**
|
3559
3669
|
* @param {Dependency} dependency the dependency
|
3560
3670
|
* @param {RuntimeSpec} runtime the runtime
|
@@ -4577,21 +4687,18 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4577
4687
|
* @returns {void}
|
4578
4688
|
*/
|
4579
4689
|
(module, push, callback) => {
|
4580
|
-
this.
|
4690
|
+
this.buildQueue.waitFor(module, err => {
|
4581
4691
|
if (err) return callback(err);
|
4582
|
-
this.
|
4692
|
+
this.processDependenciesQueue.waitFor(module, err => {
|
4583
4693
|
if (err) return callback(err);
|
4584
|
-
|
4585
|
-
|
4586
|
-
|
4587
|
-
|
4588
|
-
|
4589
|
-
|
4590
|
-
|
4591
|
-
|
4592
|
-
}
|
4593
|
-
callback();
|
4594
|
-
});
|
4694
|
+
for (const { module: m } of this.moduleGraph.getOutgoingConnections(
|
4695
|
+
module
|
4696
|
+
)) {
|
4697
|
+
const size = modules.size;
|
4698
|
+
modules.add(m);
|
4699
|
+
if (modules.size !== size) push(m);
|
4700
|
+
}
|
4701
|
+
callback();
|
4595
4702
|
});
|
4596
4703
|
});
|
4597
4704
|
},
|
package/lib/Compiler.js
CHANGED
@@ -219,9 +219,9 @@ class Compiler {
|
|
219
219
|
/** @type {string|null} */
|
220
220
|
this.recordsOutputPath = null;
|
221
221
|
this.records = {};
|
222
|
-
/** @type {Set<string>} */
|
222
|
+
/** @type {Set<string | RegExp>} */
|
223
223
|
this.managedPaths = new Set();
|
224
|
-
/** @type {Set<string>} */
|
224
|
+
/** @type {Set<string | RegExp>} */
|
225
225
|
this.immutablePaths = new Set();
|
226
226
|
|
227
227
|
/** @type {ReadonlySet<string>} */
|
package/lib/DefinePlugin.js
CHANGED
package/lib/DependenciesBlock.js
CHANGED
@@ -22,6 +22,15 @@ class DependenciesBlock {
|
|
22
22
|
this.dependencies = [];
|
23
23
|
/** @type {AsyncDependenciesBlock[]} */
|
24
24
|
this.blocks = [];
|
25
|
+
/** @type {DependenciesBlock} */
|
26
|
+
this.parent = undefined;
|
27
|
+
}
|
28
|
+
|
29
|
+
getRootBlock() {
|
30
|
+
/** @type {DependenciesBlock} */
|
31
|
+
let current = this;
|
32
|
+
while (current.parent) current = current.parent;
|
33
|
+
return current;
|
25
34
|
}
|
26
35
|
|
27
36
|
/**
|
package/lib/Dependency.js
CHANGED
@@ -91,6 +91,8 @@ class Dependency {
|
|
91
91
|
this._parentModule = undefined;
|
92
92
|
/** @type {DependenciesBlock} */
|
93
93
|
this._parentDependenciesBlock = undefined;
|
94
|
+
/** @type {number} */
|
95
|
+
this._parentDependenciesBlockIndex = -1;
|
94
96
|
// TODO check if this can be moved into ModuleDependency
|
95
97
|
/** @type {boolean} */
|
96
98
|
this.weak = false;
|