MCPcopy
hub / github.com/webpack/webpack / getRuntimeChunkDependentChunksIterable

Method getRuntimeChunkDependentChunksIterable

lib/ChunkGraph.js:1352–1400  ·  view source on GitHub ↗

* Gets runtime chunk dependent chunks iterable. * @param {Chunk} chunk the chunk * @returns {Iterable<Chunk>} iterable of chunks and include chunks from children entrypoints

(chunk)

Source from the content-addressed store, hash-verified

1350 * @returns {Iterable<Chunk>} iterable of chunks and include chunks from children entrypoints
1351 */
1352 getRuntimeChunkDependentChunksIterable(chunk) {
1353 /** @type {Chunks} */
1354 const set = new Set();
1355
1356 /** @type {Entrypoints} */
1357 const entrypoints = new Set();
1358
1359 for (const chunkGroup of chunk.groupsIterable) {
1360 if (chunkGroup instanceof Entrypoint) {
1361 const queue = [chunkGroup];
1362 while (queue.length > 0) {
1363 const current = queue.shift();
1364 if (current) {
1365 entrypoints.add(current);
1366
1367 let hasChildrenEntrypoint = false;
1368 for (const child of current.childrenIterable) {
1369 if (child instanceof Entrypoint && child.dependOn(current)) {
1370 hasChildrenEntrypoint = true;
1371 queue.push(/** @type {Entrypoint} */ (child));
1372 }
1373 }
1374 // entryChunkB: hasChildrenEntrypoint = true
1375 // entryChunkA: dependOn = entryChunkB
1376 if (hasChildrenEntrypoint) {
1377 const entrypointChunk = current.getEntrypointChunk();
1378 if (entrypointChunk !== chunk && !entrypointChunk.hasRuntime()) {
1379 // add entryChunkB to set
1380 set.add(entrypointChunk);
1381 }
1382 }
1383 }
1384 }
1385 }
1386 }
1387
1388 for (const entrypoint of entrypoints) {
1389 const entrypointChunk = entrypoint.getEntrypointChunk();
1390 const cgc = this._getChunkGraphChunk(entrypointChunk);
1391 for (const chunkGroup of cgc.entryModules.values()) {
1392 for (const c of chunkGroup.chunks) {
1393 if (c !== chunk && c !== entrypointChunk && !c.hasRuntime()) {
1394 set.add(c);
1395 }
1396 }
1397 }
1398 }
1399 return set;
1400 }
1401
1402 /**
1403 * Checks whether this chunk graph contains the chunk.

Callers 1

generateMethod · 0.80

Calls 7

_getChunkGraphChunkMethod · 0.95
dependOnMethod · 0.80
getEntrypointChunkMethod · 0.80
hasRuntimeMethod · 0.80
addMethod · 0.45
pushMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected