* Gets runtime chunk dependent chunks iterable. * @param {Chunk} chunk the chunk * @returns {Iterable<Chunk>} iterable of chunks and include chunks from children entrypoints
(chunk)
| 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. |
no test coverage detected