()
| 4713 | } |
| 4714 | |
| 4715 | createModuleHashes() { |
| 4716 | let statModulesHashed = 0; |
| 4717 | let statModulesFromCache = 0; |
| 4718 | const { chunkGraph, runtimeTemplate, moduleMemCaches2 } = this; |
| 4719 | const { hashFunction, hashDigest, hashDigestLength } = this.outputOptions; |
| 4720 | /** @type {WebpackError[]} */ |
| 4721 | const errors = []; |
| 4722 | for (const module of this.modules) { |
| 4723 | const memCache = moduleMemCaches2 && moduleMemCaches2.get(module); |
| 4724 | for (const runtime of chunkGraph.getModuleRuntimes(module)) { |
| 4725 | if (memCache) { |
| 4726 | const digest = |
| 4727 | /** @type {string} */ |
| 4728 | (memCache.get(`moduleHash-${getRuntimeKey(runtime)}`)); |
| 4729 | if (digest !== undefined) { |
| 4730 | chunkGraph.setModuleHashes( |
| 4731 | module, |
| 4732 | runtime, |
| 4733 | digest, |
| 4734 | digest.slice(0, hashDigestLength) |
| 4735 | ); |
| 4736 | statModulesFromCache++; |
| 4737 | continue; |
| 4738 | } |
| 4739 | } |
| 4740 | statModulesHashed++; |
| 4741 | const digest = this._createModuleHash( |
| 4742 | module, |
| 4743 | chunkGraph, |
| 4744 | runtime, |
| 4745 | hashFunction, |
| 4746 | runtimeTemplate, |
| 4747 | hashDigest, |
| 4748 | hashDigestLength, |
| 4749 | errors |
| 4750 | ); |
| 4751 | if (memCache) { |
| 4752 | memCache.set(`moduleHash-${getRuntimeKey(runtime)}`, digest); |
| 4753 | } |
| 4754 | } |
| 4755 | } |
| 4756 | if (errors.length > 0) { |
| 4757 | errors.sort( |
| 4758 | compareSelect((err) => err.module, compareModulesByIdentifier) |
| 4759 | ); |
| 4760 | for (const error of errors) { |
| 4761 | this.errors.push(error); |
| 4762 | } |
| 4763 | } |
| 4764 | this.logger.log( |
| 4765 | `${statModulesHashed} modules hashed, ${statModulesFromCache} from cache (${ |
| 4766 | Math.round( |
| 4767 | (100 * (statModulesHashed + statModulesFromCache)) / this.modules.size |
| 4768 | ) / 100 |
| 4769 | } variants per module in average)` |
| 4770 | ); |
| 4771 | } |
| 4772 |
no test coverage detected