* Get module graph hash with connections. * @param {ChunkGraphModule} cgm the ChunkGraphModule * @param {Module} module the module * @param {RuntimeSpec} runtime the runtime * @returns {string} hash
(cgm, module, runtime)
| 1817 | * @returns {string} hash |
| 1818 | */ |
| 1819 | _getModuleGraphHashWithConnections(cgm, module, runtime) { |
| 1820 | if (cgm.graphHashesWithConnections === undefined) { |
| 1821 | cgm.graphHashesWithConnections = new RuntimeSpecMap(); |
| 1822 | } |
| 1823 | |
| 1824 | /** |
| 1825 | * Active state to string. |
| 1826 | * @param {ConnectionState} state state |
| 1827 | * @returns {"F" | "T" | "O"} result |
| 1828 | */ |
| 1829 | const activeStateToString = (state) => { |
| 1830 | if (state === false) return "F"; |
| 1831 | if (state === true) return "T"; |
| 1832 | if (state === ModuleGraphConnection.TRANSITIVE_ONLY) return "O"; |
| 1833 | throw new Error("Not implemented active state"); |
| 1834 | }; |
| 1835 | const strict = |
| 1836 | module.buildMeta && |
| 1837 | /** @type {JavascriptModuleBuildMeta} */ (module.buildMeta) |
| 1838 | .strictHarmonyModule; |
| 1839 | return cgm.graphHashesWithConnections.provide(runtime, () => { |
| 1840 | const graphHash = this._getModuleGraphHashBigInt( |
| 1841 | cgm, |
| 1842 | module, |
| 1843 | runtime |
| 1844 | ).toString(16); |
| 1845 | const connections = this.moduleGraph.getOutgoingConnections(module); |
| 1846 | /** @type {Set<Module>} */ |
| 1847 | const activeNamespaceModules = new Set(); |
| 1848 | /** @type {Map<string, Module | Set<Module>>} */ |
| 1849 | const connectedModules = new Map(); |
| 1850 | /** |
| 1851 | * Process connection. |
| 1852 | * @param {ModuleGraphConnection} connection connection |
| 1853 | * @param {string} stateInfo state info |
| 1854 | */ |
| 1855 | const processConnection = (connection, stateInfo) => { |
| 1856 | const module = connection.module; |
| 1857 | stateInfo += module.getExportsType(this.moduleGraph, strict); |
| 1858 | // cspell:word Tnamespace |
| 1859 | if (stateInfo === "Tnamespace") { |
| 1860 | activeNamespaceModules.add(module); |
| 1861 | } else { |
| 1862 | const oldModule = connectedModules.get(stateInfo); |
| 1863 | if (oldModule === undefined) { |
| 1864 | connectedModules.set(stateInfo, module); |
| 1865 | } else if (oldModule instanceof Set) { |
| 1866 | oldModule.add(module); |
| 1867 | } else if (oldModule !== module) { |
| 1868 | connectedModules.set(stateInfo, new Set([oldModule, module])); |
| 1869 | } |
| 1870 | } |
| 1871 | }; |
| 1872 | if (runtime === undefined || typeof runtime === "string") { |
| 1873 | for (const connection of connections) { |
| 1874 | const state = connection.getActiveState(runtime); |
| 1875 | if (state === false) continue; |
| 1876 | processConnection(connection, state === true ? "T" : "O"); |
no test coverage detected