* Returns the connection. * @param {Dependency} dependency the dependency to look for a referenced module * @returns {ModuleGraphConnection | undefined} the connection
(dependency)
| 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. |
no test coverage detected