MCPcopy
hub / github.com/webpack/webpack / hasModuleInGraph

Method hasModuleInGraph

lib/ChunkGraph.js:920–943  ·  view source on GitHub ↗

* Checks whether this chunk graph contains the chunk. * @param {Chunk} chunk the chunk * @param {ModuleFilterPredicate} filterFn predicate function used to filter modules * @param {ChunkFilterPredicate=} filterChunkFn predicate function used to filter chunks * @returns {boolean} return true

(chunk, filterFn, filterChunkFn)

Source from the content-addressed store, hash-verified

918 * @returns {boolean} return true if module exists in graph
919 */
920 hasModuleInGraph(chunk, filterFn, filterChunkFn) {
921 const queue = new Set(chunk.groupsIterable);
922 /** @type {Set<Chunk>} */
923 const chunksProcessed = new Set();
924
925 for (const chunkGroup of queue) {
926 for (const innerChunk of chunkGroup.chunks) {
927 if (!chunksProcessed.has(innerChunk)) {
928 chunksProcessed.add(innerChunk);
929 if (!filterChunkFn || filterChunkFn(innerChunk, this)) {
930 for (const module of this.getChunkModulesIterable(innerChunk)) {
931 if (filterFn(module)) {
932 return true;
933 }
934 }
935 }
936 }
937 }
938 for (const child of chunkGroup.childrenIterable) {
939 queue.add(child);
940 }
941 }
942 return false;
943 }
944
945 /**
946 * Compares the provided values and returns their ordering.

Callers

nothing calls this directly

Calls 3

hasMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected