MCPcopy
hub / github.com/webpack/webpack / updateModule

Method updateModule

lib/ModuleGraph.js:292–308  ·  lib/ModuleGraph.js::ModuleGraph.updateModule

* Updates module using the provided dependency. * @param {Dependency} dependency the referencing dependency * @param {Module} module the referenced module * @returns {void}

(dependency, module)

Source from the content-addressed store, hash-verified

290 * @returns {void}
291 */
292 updateModule(dependency, module) {
293 const connection =
294 /** @type {ModuleGraphConnection} */
295 (this.getConnection(dependency));
296 if (connection.module === module) return;
297 const newConnection = connection.clone();
298 newConnection.module = module;
299 this._dependencyMap.set(dependency, newConnection);
300 connection.setActive(false);
301 const originMgm = this._getModuleGraphModule(
302 /** @type {Module} */ (connection.originModule)
303 );
304 /** @type {OutgoingConnections} */
305 (originMgm.outgoingConnections).add(newConnection);
306 const targetMgm = this._getModuleGraphModule(module);
307 targetMgm.incomingConnections.add(newConnection);
308 }
309
310 /**
311 * Updates parent using the provided dependency.

Callers 1

Calls 6

getConnectionMethod · 0.95
_getModuleGraphModuleMethod · 0.95
setActiveMethod · 0.80
cloneMethod · 0.45
setMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected