MCPcopy
hub / github.com/webpack/webpack / countOccurs

Method countOccurs

lib/ids/OccurrenceModuleIdsPlugin.js:105–123  ·  view source on GitHub ↗
(module)

Source from the content-addressed store, hash-verified

103 * @returns {number} count of occurs
104 */
105 const countOccurs = (module) => {
106 let sum = 0;
107 for (const [
108 originModule,
109 connections
110 ] of moduleGraph.getIncomingConnectionsByOriginModule(module)) {
111 if (!originModule) continue;
112 const chunkModules =
113 chunkGraph.getNumberOfModuleChunks(originModule);
114 for (const c of connections) {
115 if (!c.isTargetActive(undefined)) continue;
116 if (!c.dependency) continue;
117 const factor = c.dependency.getNumberOfIdOccurrences();
118 if (factor === 0) continue;
119 sum += factor * chunkModules;
120 }
121 }
122 return sum;
123 };
124
125 if (this.options.prioritiseInitial) {
126 for (const m of modulesInOccurrenceOrder) {

Callers

nothing calls this directly

Tested by

no test coverage detected