MCPcopy
hub / github.com/webpack/webpack / moveModuleConnections

Method moveModuleConnections

lib/ModuleGraph.js:460–489  ·  lib/ModuleGraph.js::ModuleGraph.moveModuleConnections

* Move module connections. * @param {Module} oldModule the old referencing module * @param {Module} newModule the new referencing module * @param {FilterConnection} filterConnection filter predicate for replacement * @returns {void}

(oldModule, newModule, filterConnection)

Source from the content-addressed store, hash-verified

458 * @returns {void}
459 */
460 moveModuleConnections(oldModule, newModule, filterConnection) {
461 if (oldModule === newModule) return;
462 const oldMgm = this._getModuleGraphModule(oldModule);
463 const newMgm = this._getModuleGraphModule(newModule);
464 class="cm">// Outgoing connections
465 const oldConnections = oldMgm.outgoingConnections;
466 if (oldConnections !== undefined) {
467 if (newMgm.outgoingConnections === undefined) {
468 newMgm.outgoingConnections = new SortableSet();
469 }
470 const newConnections = newMgm.outgoingConnections;
471 for (const connection of oldConnections) {
472 if (filterConnection(connection)) {
473 connection.originModule = newModule;
474 newConnections.add(connection);
475 oldConnections.delete(connection);
476 }
477 }
478 }
479 class="cm">// Incoming connections
480 const oldConnections2 = oldMgm.incomingConnections;
481 const newConnections2 = newMgm.incomingConnections;
482 for (const connection of oldConnections2) {
483 if (filterConnection(connection)) {
484 connection.module = newModule;
485 newConnections2.add(connection);
486 oldConnections2.delete(connection);
487 }
488 }
489 }
490
491 /**
492 * Copies outgoing module connections.

Callers 1

integrateMethod · 0.80

Calls 3

_getModuleGraphModuleMethod · 0.95
addMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected