* Adds the provided module to the compilation. * @param {Module} module module to be added that was created * @param {ModuleCallback} callback returns the module in the compilation, * it could be the passed one (if new), or an already existing in the compilation * @returns {void}
(module, callback)
| 1617 | * @returns {void} |
| 1618 | */ |
| 1619 | _addModule(module, callback) { |
| 1620 | const identifier = module.identifier(); |
| 1621 | const alreadyAddedModule = this._modules.get(identifier); |
| 1622 | if (alreadyAddedModule) { |
| 1623 | return callback(null, alreadyAddedModule); |
| 1624 | } |
| 1625 | |
| 1626 | const currentProfile = this.profile |
| 1627 | ? this.moduleGraph.getProfile(module) |
| 1628 | : undefined; |
| 1629 | if (currentProfile !== undefined) { |
| 1630 | currentProfile.markRestoringStart(); |
| 1631 | } |
| 1632 | |
| 1633 | this._modulesCache.get(identifier, null, (err, cacheModule) => { |
| 1634 | if (err) return callback(new ModuleRestoreError(module, err)); |
| 1635 | |
| 1636 | if (currentProfile !== undefined) { |
| 1637 | currentProfile.markRestoringEnd(); |
| 1638 | currentProfile.markIntegrationStart(); |
| 1639 | } |
| 1640 | |
| 1641 | if (cacheModule) { |
| 1642 | cacheModule.updateCacheModule(module); |
| 1643 | |
| 1644 | module = cacheModule; |
| 1645 | } |
| 1646 | this._modules.set(identifier, module); |
| 1647 | this.modules.add(module); |
| 1648 | if (this._backCompat) { |
| 1649 | ModuleGraph.setModuleGraphForModule(module, this.moduleGraph); |
| 1650 | } |
| 1651 | if (currentProfile !== undefined) { |
| 1652 | currentProfile.markIntegrationEnd(); |
| 1653 | } |
| 1654 | callback(null, module); |
| 1655 | }); |
| 1656 | } |
| 1657 | |
| 1658 | /** |
| 1659 | * Fetches a module from a compilation by its identifier |
nothing calls this directly
no test coverage detected