MCPcopy
hub / github.com/webpack/webpack / copyOutgoingModuleConnections

Method copyOutgoingModuleConnections

lib/ModuleGraph.js:498–521  ·  view source on GitHub ↗

* Copies outgoing 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

496 * @returns {void}
497 */
498 copyOutgoingModuleConnections(oldModule, newModule, filterConnection) {
499 if (oldModule === newModule) return;
500 const oldMgm = this._getModuleGraphModule(oldModule);
501 const newMgm = this._getModuleGraphModule(newModule);
502 // Outgoing connections
503 const oldConnections = oldMgm.outgoingConnections;
504 if (oldConnections !== undefined) {
505 if (newMgm.outgoingConnections === undefined) {
506 newMgm.outgoingConnections = new SortableSet();
507 }
508 const newConnections = newMgm.outgoingConnections;
509 for (const connection of oldConnections) {
510 if (filterConnection(connection)) {
511 const newConnection = connection.clone();
512 newConnection.originModule = newModule;
513 newConnections.add(newConnection);
514 if (newConnection.module !== undefined) {
515 const otherMgm = this._getModuleGraphModule(newConnection.module);
516 otherMgm.incomingConnections.add(newConnection);
517 }
518 }
519 }
520 }
521 }
522
523 /**
524 * Adds the provided module to the module graph.

Callers 1

integrateMethod · 0.80

Calls 3

_getModuleGraphModuleMethod · 0.95
cloneMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected