MCPcopy
hub / github.com/webpack/webpack / getConnection

Method getConnection

lib/ModuleGraph.js:549–580  ·  lib/ModuleGraph.js::ModuleGraph.getConnection

* Returns the connection. * @param {Dependency} dependency the dependency to look for a referenced module * @returns {ModuleGraphConnection | undefined} the connection

(dependency)

Source from the content-addressed store, hash-verified

547 * @returns {ModuleGraphConnection | undefined} the connection
548 */
549 getConnection(dependency) {
550 const connection = this._dependencyMap.get(dependency);
551 if (connection === undefined) {
552 const module = this.getParentModule(dependency);
553 if (module !== undefined) {
554 const mgm = this._getModuleGraphModule(module);
555 if (
556 mgm._unassignedConnections &&
557 mgm._unassignedConnections.length !== 0
558 ) {
559 /** @type {undefined | ModuleGraphConnection} */
560 let foundConnection;
561 for (const connection of mgm._unassignedConnections) {
562 this._dependencyMap.set(
563 /** @type {Dependency} */ (connection.dependency),
564 connection
565 );
566 if (connection.dependency === dependency) {
567 foundConnection = connection;
568 }
569 }
570 mgm._unassignedConnections.length = 0;
571 if (foundConnection !== undefined) {
572 return foundConnection;
573 }
574 }
575 }
576 this._dependencyMap.set(dependency, null);
577 return;
578 }
579 return connection === null ? undefined : connection;
580 }
581
582 /**
583 * Returns the referenced module.

Callers 15

updateModuleMethod · 0.95
removeConnectionMethod · 0.95
addExplanationMethod · 0.95
getResolvedModuleMethod · 0.95
getModuleMethod · 0.95
getOriginMethod · 0.95
getResolvedOriginMethod · 0.95
processModuleMethod · 0.80
_getImportsMethod · 0.80
applyMethod · 0.80
applyMethod · 0.80

Calls 4

getParentModuleMethod · 0.95
_getModuleGraphModuleMethod · 0.95
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected