| 1066 | }; |
| 1067 | |
| 1068 | const processChunkGroupsForMerging = () => { |
| 1069 | statProcessedChunkGroupsForMerging += chunkGroupsForMerging.size; |
| 1070 | |
| 1071 | class="cm">// Execute the merge |
| 1072 | for (const [info, processBlock] of chunkGroupsForMerging) { |
| 1073 | const availableModulesToBeMerged = info.availableModulesToBeMerged; |
| 1074 | const cachedMinAvailableModules = info.minAvailableModules; |
| 1075 | let minAvailableModules = cachedMinAvailableModules; |
| 1076 | |
| 1077 | statMergedAvailableModuleSets += availableModulesToBeMerged.length; |
| 1078 | |
| 1079 | for (const availableModules of availableModulesToBeMerged) { |
| 1080 | if (minAvailableModules === undefined) { |
| 1081 | minAvailableModules = availableModules; |
| 1082 | } else { |
| 1083 | minAvailableModules &= availableModules; |
| 1084 | } |
| 1085 | } |
| 1086 | |
| 1087 | const changed = minAvailableModules !== cachedMinAvailableModules; |
| 1088 | |
| 1089 | availableModulesToBeMerged.length = 0; |
| 1090 | if (changed) { |
| 1091 | info.minAvailableModules = minAvailableModules; |
| 1092 | info.resultingAvailableModules = undefined; |
| 1093 | outdatedChunkGroupInfo.add(info); |
| 1094 | } |
| 1095 | |
| 1096 | if (processBlock) { |
| 1097 | let blocks = blocksByChunkGroups.get(info); |
| 1098 | if (!blocks) { |
| 1099 | blocksByChunkGroups.set(info, (blocks = new Set())); |
| 1100 | } |
| 1101 | |
| 1102 | class="cm">// Whether to walk block depends on minAvailableModules and input block. |
| 1103 | class="cm">// We can treat creating chunk group as a function with 2 input, entry block and minAvailableModules |
| 1104 | class="cm">// If input is the same, we can skip re-walk |
| 1105 | let needWalkBlock = !info.initialized || changed; |
| 1106 | if (!blocks.has(processBlock.block)) { |
| 1107 | needWalkBlock = true; |
| 1108 | blocks.add(processBlock.block); |
| 1109 | } |
| 1110 | |
| 1111 | if (needWalkBlock) { |
| 1112 | info.initialized = true; |
| 1113 | queueDelayed.push(processBlock); |
| 1114 | } |
| 1115 | } |
| 1116 | } |
| 1117 | chunkGroupsForMerging.clear(); |
| 1118 | }; |
| 1119 | |
| 1120 | const processChunkGroupsForCombining = () => { |
| 1121 | for (const info of chunkGroupsForCombining) { |