MCPcopy
hub / github.com/webpack/webpack / hasReasonForChunk

Method hasReasonForChunk

lib/Module.js:896–913  ·  view source on GitHub ↗

* Checks whether this module contains the chunk. * @param {Chunk} chunk a chunk * @param {ModuleGraph} moduleGraph the module graph * @param {ChunkGraph} chunkGraph the chunk graph * @returns {boolean} true, if the module has any reason why "chunk" should be included

(chunk, moduleGraph, chunkGraph)

Source from the content-addressed store, hash-verified

894 * @returns {boolean} true, if the module has any reason why "chunk" should be included
895 */
896 hasReasonForChunk(chunk, moduleGraph, chunkGraph) {
897 // check for each reason if we need the chunk
898 for (const [
899 fromModule,
900 connections
901 ] of moduleGraph.getIncomingConnectionsByOriginModule(this)) {
902 if (!connections.some((c) => c.isTargetActive(chunk.runtime))) continue;
903 for (const originChunk of chunkGraph.getModuleChunksIterable(
904 /** @type {Module} */ (fromModule)
905 )) {
906 // return true if module this is not reachable from originChunk when ignoring chunk
907 if (!this.isAccessibleInChunk(chunkGraph, originChunk, chunk)) {
908 return true;
909 }
910 }
911 }
912 return false;
913 }
914
915 /**
916 * Checks whether this module contains the module graph.

Callers 1

Calls 4

isAccessibleInChunkMethod · 0.95
isTargetActiveMethod · 0.80

Tested by

no test coverage detected