* Processes the provided old module. * @param {Module} oldModule the replaced module * @param {Module} newModule the replacing module * @returns {void}
(oldModule, newModule)
| 491 | * @returns {void} |
| 492 | */ |
| 493 | replaceModule(oldModule, newModule) { |
| 494 | const oldCgm = this._getChunkGraphModule(oldModule); |
| 495 | const newCgm = this._getChunkGraphModule(newModule); |
| 496 | |
| 497 | for (const chunk of oldCgm.chunks) { |
| 498 | const cgc = this._getChunkGraphChunk(chunk); |
| 499 | cgc.modules.delete(oldModule); |
| 500 | cgc.modules.add(newModule); |
| 501 | newCgm.chunks.add(chunk); |
| 502 | } |
| 503 | oldCgm.chunks.clear(); |
| 504 | |
| 505 | if (oldCgm.entryInChunks !== undefined) { |
| 506 | if (newCgm.entryInChunks === undefined) { |
| 507 | newCgm.entryInChunks = new Set(); |
| 508 | } |
| 509 | for (const chunk of oldCgm.entryInChunks) { |
| 510 | const cgc = this._getChunkGraphChunk(chunk); |
| 511 | const old = /** @type {Entrypoint} */ (cgc.entryModules.get(oldModule)); |
| 512 | /** @type {EntryModules} */ |
| 513 | const newEntryModules = new Map(); |
| 514 | for (const [m, cg] of cgc.entryModules) { |
| 515 | if (m === oldModule) { |
| 516 | newEntryModules.set(newModule, old); |
| 517 | } else { |
| 518 | newEntryModules.set(m, cg); |
| 519 | } |
| 520 | } |
| 521 | cgc.entryModules = newEntryModules; |
| 522 | newCgm.entryInChunks.add(chunk); |
| 523 | } |
| 524 | oldCgm.entryInChunks = undefined; |
| 525 | } |
| 526 | |
| 527 | if (oldCgm.runtimeInChunks !== undefined) { |
| 528 | if (newCgm.runtimeInChunks === undefined) { |
| 529 | newCgm.runtimeInChunks = new Set(); |
| 530 | } |
| 531 | for (const chunk of oldCgm.runtimeInChunks) { |
| 532 | const cgc = this._getChunkGraphChunk(chunk); |
| 533 | cgc.runtimeModules.delete(/** @type {RuntimeModule} */ (oldModule)); |
| 534 | cgc.runtimeModules.add(/** @type {RuntimeModule} */ (newModule)); |
| 535 | newCgm.runtimeInChunks.add(chunk); |
| 536 | if ( |
| 537 | cgc.fullHashModules !== undefined && |
| 538 | cgc.fullHashModules.has(/** @type {RuntimeModule} */ (oldModule)) |
| 539 | ) { |
| 540 | cgc.fullHashModules.delete(/** @type {RuntimeModule} */ (oldModule)); |
| 541 | cgc.fullHashModules.add(/** @type {RuntimeModule} */ (newModule)); |
| 542 | } |
| 543 | if ( |
| 544 | cgc.dependentHashModules !== undefined && |
| 545 | cgc.dependentHashModules.has(/** @type {RuntimeModule} */ (oldModule)) |
| 546 | ) { |
| 547 | cgc.dependentHashModules.delete( |
| 548 | /** @type {RuntimeModule} */ (oldModule) |
| 549 | ); |
| 550 | cgc.dependentHashModules.add( |
no test coverage detected