* Get module hash info. * @template T * @param {Module} module the module * @param {RuntimeSpecMap<T>} hashes hashes data * @param {RuntimeSpec} runtime the runtime * @returns {T} hash
(module, hashes, runtime)
| 1568 | * @returns {T} hash |
| 1569 | */ |
| 1570 | _getModuleHashInfo(module, hashes, runtime) { |
| 1571 | if (!hashes) { |
| 1572 | throw new Error( |
| 1573 | `Module ${module.identifier()} has no hash info for runtime ${runtimeToString( |
| 1574 | runtime |
| 1575 | )} (hashes not set at all)` |
| 1576 | ); |
| 1577 | } else if (runtime === undefined) { |
| 1578 | const hashInfoItems = new Set(hashes.values()); |
| 1579 | if (hashInfoItems.size !== 1) { |
| 1580 | throw new Error( |
| 1581 | `No unique hash info entry for unspecified runtime for ${module.identifier()} (existing runtimes: ${Array.from( |
| 1582 | hashes.keys(), |
| 1583 | (r) => runtimeToString(r) |
| 1584 | ).join(", ")}). |
| 1585 | Caller might not support runtime-dependent code generation (opt-out via optimization.usedExports: "global").` |
| 1586 | ); |
| 1587 | } |
| 1588 | return /** @type {T} */ (first(hashInfoItems)); |
| 1589 | } else { |
| 1590 | const hashInfo = hashes.get(runtime); |
| 1591 | if (!hashInfo) { |
| 1592 | throw new Error( |
| 1593 | `Module ${module.identifier()} has no hash info for runtime ${runtimeToString( |
| 1594 | runtime |
| 1595 | )} (available runtimes ${Array.from( |
| 1596 | hashes.keys(), |
| 1597 | runtimeToString |
| 1598 | ).join(", ")})` |
| 1599 | ); |
| 1600 | } |
| 1601 | return hashInfo; |
| 1602 | } |
| 1603 | } |
| 1604 | |
| 1605 | /** |
| 1606 | * Checks whether this chunk graph contains the module. |
no test coverage detected