webpack 5.58.1 → 5.60.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/hot/lazy-compilation-node.js +3 -1
- package/lib/Compilation.js +174 -108
- package/lib/Compiler.js +2 -2
- package/lib/DefinePlugin.js +1 -1
- package/lib/FileSystemInfo.js +112 -30
- package/lib/NormalModule.js +37 -14
- package/lib/RuntimeTemplate.js +1 -1
- package/lib/WebpackOptionsApply.js +12 -11
- package/lib/cache/AddManagedPathsPlugin.js +2 -2
- package/lib/cache/PackFileCacheStrategy.js +6 -3
- package/lib/config/defaults.js +65 -43
- package/lib/config/normalization.js +6 -1
- package/lib/hmr/LazyCompilationPlugin.js +9 -5
- package/lib/hmr/lazyCompilationBackend.js +42 -10
- package/lib/optimize/ConcatenatedModule.js +1 -1
- package/lib/optimize/SplitChunksPlugin.js +57 -4
- package/lib/schemes/HttpUriPlugin.js +108 -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 +324 -55
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.json +28 -0
- package/types.d.ts +140 -89
@@ -9,7 +9,9 @@ exports.keepAlive = function (options) {
|
|
9
9
|
var active = options.active;
|
10
10
|
var module = options.module;
|
11
11
|
var response;
|
12
|
-
var request =
|
12
|
+
var request = (
|
13
|
+
urlBase.startsWith("https") ? require("https") : require("http")
|
14
|
+
).request(
|
13
15
|
urlBase + data,
|
14
16
|
{
|
15
17
|
agent: false,
|
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>} */
|
@@ -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
|
-
|
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
|
1462
|
-
if (
|
1463
|
-
if (
|
1464
|
-
if (
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
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
|
1510
|
+
);
|
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
|
1470
1523
|
);
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
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
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
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 (
|
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
|
-
|
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(
|
1763
|
-
unsafeCacheData.set(
|
1828
|
+
if (!unsafeCacheData.has(unsafeCacheableModule)) {
|
1829
|
+
unsafeCacheData.set(
|
1830
|
+
unsafeCacheableModule,
|
1831
|
+
unsafeCacheableModule.getUnsafeCacheData()
|
1832
|
+
);
|
1764
1833
|
}
|
1765
1834
|
} else {
|
1766
1835
|
applyFactoryResultDependencies();
|
@@ -1814,7 +1883,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1814
1883
|
creatingModuleDuringBuildSet
|
1815
1884
|
);
|
1816
1885
|
}
|
1817
|
-
creatingModuleDuringBuildSet.add(
|
1886
|
+
creatingModuleDuringBuildSet.add(module);
|
1818
1887
|
|
1819
1888
|
// When building is blocked by another module
|
1820
1889
|
// search for a cycle, cancel the cycle by throwing
|
@@ -4618,21 +4687,18 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4618
4687
|
* @returns {void}
|
4619
4688
|
*/
|
4620
4689
|
(module, push, callback) => {
|
4621
|
-
this.
|
4690
|
+
this.buildQueue.waitFor(module, err => {
|
4622
4691
|
if (err) return callback(err);
|
4623
|
-
this.
|
4692
|
+
this.processDependenciesQueue.waitFor(module, err => {
|
4624
4693
|
if (err) return callback(err);
|
4625
|
-
|
4626
|
-
|
4627
|
-
|
4628
|
-
|
4629
|
-
|
4630
|
-
|
4631
|
-
|
4632
|
-
|
4633
|
-
}
|
4634
|
-
callback();
|
4635
|
-
});
|
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();
|
4636
4702
|
});
|
4637
4703
|
});
|
4638
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>} */
|