@@ -30,6 +30,7 @@ const findGraphRoots = require("./findGraphRoots");
3030/** @import AsyncDependenciesBlock from "./AsyncDependenciesBlock" */
3131/** @import Chunk, { Chunks, Entrypoints, ChunkId } from "./Chunk" */
3232/** @import ChunkGroup from "./ChunkGroup" */
33+ /** @import Dependency from "./Dependency" */
3334/** @import Entrypoint from "./Entrypoint" */
3435/**
3536 * @import Module, {
@@ -1938,9 +1939,21 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
19381939 /** @type {Map<string, Module | Set<Module>> } */
19391940 const connectedModules = new Map ( ) ;
19401941 // a dependency whose target is missing has no connection, so without
1941- // this count it hashes like one whose target is inactive, while templates
1942- // print a missing-module throw only for the first.
1943- let inactiveConnections = 0 ;
1942+ // these it hashes like one whose target is inactive, while templates
1943+ // print a missing-module throw only for the first
1944+ /** @type {string[] | undefined } */
1945+ let inactiveRequests ;
1946+ /**
1947+ * Records an inactive connection by its request, as templates print nothing of its target.
1948+ * @param {ModuleGraphConnection } connection inactive connection
1949+ */
1950+ const addInactive = ( connection ) => {
1951+ // only connections without an origin module lack a dependency
1952+ const dependency = /** @type {Dependency } */ ( connection . dependency ) ;
1953+ ( inactiveRequests || ( inactiveRequests = [ ] ) ) . push (
1954+ `${ dependency . getResourceIdentifier ( ) } `
1955+ ) ;
1956+ } ;
19441957 /**
19451958 * Process connection.
19461959 * @param {ModuleGraphConnection } connection connection
@@ -1967,7 +1980,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
19671980 for ( const connection of connections ) {
19681981 const state = connection . getActiveState ( runtime ) ;
19691982 if ( state === false ) {
1970- inactiveConnections ++ ;
1983+ addInactive ( connection ) ;
19711984 continue ;
19721985 }
19731986 processConnection ( connection , state === true ? "T" : "O" ) ;
@@ -1992,7 +2005,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
19922005 }
19932006 if ( sameState ) {
19942007 if ( firstState === false ) {
1995- inactiveConnections ++ ;
2008+ addInactive ( connection ) ;
19962009 continue ;
19972010 }
19982011 stateInfo = activeStateToString (
@@ -2007,7 +2020,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
20072020 if (
20082021 activeNamespaceModules . size === 0 &&
20092022 connectedModules . size === 0 &&
2010- inactiveConnections === 0
2023+ inactiveRequests === undefined
20112024 ) {
20122025 return graphHash ;
20132026 }
@@ -2059,7 +2072,11 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
20592072 addModuleToHash ( modules ) ;
20602073 }
20612074 }
2062- if ( inactiveConnections > 0 ) hash . update ( `F${ inactiveConnections } ` ) ;
2075+ if ( inactiveRequests !== undefined ) {
2076+ // connections arrive as resolutions finish, so sort like connectedModules
2077+ if ( inactiveRequests . length > 1 ) inactiveRequests . sort ( ) ;
2078+ for ( const request of inactiveRequests ) hash . update ( request ) ;
2079+ }
20632080 hash . update ( graphHash ) ;
20642081 return hash . digest ( "hex" ) ;
20652082 } ) ;
0 commit comments