webpack 4.44.1 → 4.44.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/lib/buildChunkGraph.js +44 -56
- package/package.json +1 -1
package/lib/buildChunkGraph.js
CHANGED
@@ -38,8 +38,8 @@ const GraphHelpers = require("./GraphHelpers");
|
|
38
38
|
*/
|
39
39
|
|
40
40
|
/**
|
41
|
-
* @typedef {Object}
|
42
|
-
* @property {
|
41
|
+
* @typedef {Object} BlockChunkGroupConnection
|
42
|
+
* @property {ChunkGroupInfo} originChunkGroupInfo origin chunk group
|
43
43
|
* @property {ChunkGroup} chunkGroup referenced chunk group
|
44
44
|
*/
|
45
45
|
|
@@ -143,7 +143,7 @@ const extraceBlockInfoMap = compilation => {
|
|
143
143
|
* @param {Compilation} compilation the compilation
|
144
144
|
* @param {Entrypoint[]} inputChunkGroups input groups
|
145
145
|
* @param {Map<ChunkGroup, ChunkGroupInfo>} chunkGroupInfoMap mapping from chunk group to available modules
|
146
|
-
* @param {Map<
|
146
|
+
* @param {Map<AsyncDependenciesBlock, BlockChunkGroupConnection[]>} blockConnections connection for blocks
|
147
147
|
* @param {Set<DependenciesBlock>} blocksWithNestedBlocks flag for blocks that have nested blocks
|
148
148
|
* @param {Set<ChunkGroup>} allCreatedChunkGroups filled with all chunk groups that are created here
|
149
149
|
*/
|
@@ -151,7 +151,7 @@ const visitModules = (
|
|
151
151
|
compilation,
|
152
152
|
inputChunkGroups,
|
153
153
|
chunkGroupInfoMap,
|
154
|
-
|
154
|
+
blockConnections,
|
155
155
|
blocksWithNestedBlocks,
|
156
156
|
allCreatedChunkGroups
|
157
157
|
) => {
|
@@ -229,6 +229,8 @@ const visitModules = (
|
|
229
229
|
let chunk;
|
230
230
|
/** @type {ChunkGroup} */
|
231
231
|
let chunkGroup;
|
232
|
+
/** @type {ChunkGroupInfo} */
|
233
|
+
let chunkGroupInfo;
|
232
234
|
/** @type {DependenciesBlock} */
|
233
235
|
let block;
|
234
236
|
/** @type {Set<Module>} */
|
@@ -263,17 +265,17 @@ const visitModules = (
|
|
263
265
|
blockChunkGroups.set(b, c);
|
264
266
|
allCreatedChunkGroups.add(c);
|
265
267
|
}
|
268
|
+
blockConnections.set(b, []);
|
266
269
|
} else {
|
267
270
|
// TODO webpack 5 remove addOptions check
|
268
271
|
if (c.addOptions) c.addOptions(b.groupOptions);
|
269
272
|
c.addOrigin(module, b.loc, b.request);
|
270
273
|
}
|
271
274
|
|
272
|
-
// 2. We store the
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
block: b,
|
275
|
+
// 2. We store the connection for the block
|
276
|
+
// to connect it later if needed
|
277
|
+
blockConnections.get(b).push({
|
278
|
+
originChunkGroupInfo: chunkGroupInfo,
|
277
279
|
chunkGroup: c
|
278
280
|
});
|
279
281
|
|
@@ -306,7 +308,7 @@ const visitModules = (
|
|
306
308
|
chunk = queueItem.chunk;
|
307
309
|
if (chunkGroup !== queueItem.chunkGroup) {
|
308
310
|
chunkGroup = queueItem.chunkGroup;
|
309
|
-
|
311
|
+
chunkGroupInfo = chunkGroupInfoMap.get(chunkGroup);
|
310
312
|
minAvailableModules = chunkGroupInfo.minAvailableModules;
|
311
313
|
skippedItems = chunkGroupInfo.skippedItems;
|
312
314
|
}
|
@@ -583,17 +585,14 @@ const visitModules = (
|
|
583
585
|
/**
|
584
586
|
*
|
585
587
|
* @param {Set<DependenciesBlock>} blocksWithNestedBlocks flag for blocks that have nested blocks
|
586
|
-
* @param {Map<
|
588
|
+
* @param {Map<AsyncDependenciesBlock, BlockChunkGroupConnection[]>} blockConnections connection for blocks
|
587
589
|
* @param {Map<ChunkGroup, ChunkGroupInfo>} chunkGroupInfoMap mapping from chunk group to available modules
|
588
590
|
*/
|
589
591
|
const connectChunkGroups = (
|
590
592
|
blocksWithNestedBlocks,
|
591
|
-
|
593
|
+
blockConnections,
|
592
594
|
chunkGroupInfoMap
|
593
595
|
) => {
|
594
|
-
/** @type {Set<Module>} */
|
595
|
-
let resultingAvailableModules;
|
596
|
-
|
597
596
|
/**
|
598
597
|
* Helper function to check if all modules of a chunk are available
|
599
598
|
*
|
@@ -611,49 +610,38 @@ const connectChunkGroups = (
|
|
611
610
|
};
|
612
611
|
|
613
612
|
// For each edge in the basic chunk graph
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
613
|
+
for (const [block, connections] of blockConnections) {
|
614
|
+
// 1. Check if connection is needed
|
615
|
+
// When none of the dependencies need to be connected
|
616
|
+
// we can skip all of them
|
617
|
+
// It's not possible to filter each item so it doesn't create inconsistent
|
618
|
+
// connections and modules can only create one version
|
619
|
+
// TODO maybe decide this per runtime
|
620
|
+
if (
|
621
|
+
// TODO is this needed?
|
622
|
+
!blocksWithNestedBlocks.has(block) &&
|
623
|
+
connections.every(({ chunkGroup, originChunkGroupInfo }) =>
|
624
|
+
areModulesAvailable(
|
625
|
+
chunkGroup,
|
626
|
+
originChunkGroupInfo.resultingAvailableModules
|
627
|
+
)
|
628
|
+
)
|
629
|
+
) {
|
630
|
+
continue;
|
625
631
|
}
|
626
|
-
return true;
|
627
|
-
};
|
628
|
-
|
629
|
-
// For all deps, check if chunk groups need to be connected
|
630
|
-
for (const [chunkGroup, deps] of chunkDependencies) {
|
631
|
-
if (deps.length === 0) continue;
|
632
|
-
|
633
|
-
// 1. Get info from chunk group info map
|
634
|
-
const info = chunkGroupInfoMap.get(chunkGroup);
|
635
|
-
resultingAvailableModules = info.resultingAvailableModules;
|
636
632
|
|
637
633
|
// 2. Foreach edge
|
638
|
-
for (let i = 0; i <
|
639
|
-
const
|
634
|
+
for (let i = 0; i < connections.length; i++) {
|
635
|
+
const { chunkGroup, originChunkGroupInfo } = connections[i];
|
640
636
|
|
641
|
-
//
|
642
|
-
|
643
|
-
if (!filterFn(dep)) {
|
644
|
-
continue;
|
645
|
-
}
|
646
|
-
const depChunkGroup = dep.chunkGroup;
|
647
|
-
const depBlock = dep.block;
|
637
|
+
// 3. Connect block with chunk
|
638
|
+
GraphHelpers.connectDependenciesBlockAndChunkGroup(block, chunkGroup);
|
648
639
|
|
649
|
-
//
|
650
|
-
GraphHelpers.
|
651
|
-
|
652
|
-
|
640
|
+
// 4. Connect chunk with parent
|
641
|
+
GraphHelpers.connectChunkGroupParentAndChild(
|
642
|
+
originChunkGroupInfo.chunkGroup,
|
643
|
+
chunkGroup
|
653
644
|
);
|
654
|
-
|
655
|
-
// 6. Connect chunk with parent
|
656
|
-
GraphHelpers.connectChunkGroupParentAndChild(chunkGroup, depChunkGroup);
|
657
645
|
}
|
658
646
|
}
|
659
647
|
};
|
@@ -685,8 +673,8 @@ const cleanupUnconnectedGroups = (compilation, allCreatedChunkGroups) => {
|
|
685
673
|
const buildChunkGraph = (compilation, inputChunkGroups) => {
|
686
674
|
// SHARED STATE
|
687
675
|
|
688
|
-
/** @type {Map<
|
689
|
-
const
|
676
|
+
/** @type {Map<AsyncDependenciesBlock, BlockChunkGroupConnection[]>} */
|
677
|
+
const blockConnections = new Map();
|
690
678
|
|
691
679
|
/** @type {Set<ChunkGroup>} */
|
692
680
|
const allCreatedChunkGroups = new Set();
|
@@ -703,7 +691,7 @@ const buildChunkGraph = (compilation, inputChunkGroups) => {
|
|
703
691
|
compilation,
|
704
692
|
inputChunkGroups,
|
705
693
|
chunkGroupInfoMap,
|
706
|
-
|
694
|
+
blockConnections,
|
707
695
|
blocksWithNestedBlocks,
|
708
696
|
allCreatedChunkGroups
|
709
697
|
);
|
@@ -712,7 +700,7 @@ const buildChunkGraph = (compilation, inputChunkGroups) => {
|
|
712
700
|
|
713
701
|
connectChunkGroups(
|
714
702
|
blocksWithNestedBlocks,
|
715
|
-
|
703
|
+
blockConnections,
|
716
704
|
chunkGroupInfoMap
|
717
705
|
);
|
718
706
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "4.44.
|
3
|
+
"version": "4.44.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",
|