@@ -1149,7 +1149,7 @@ class DefinePlugin {
11491149 const chainRoot = isMeta ? "import.meta" : chainParts [ 0 ] ;
11501150 const chainPrefix = chainParts . slice ( isMeta ? 2 : 1 ) ;
11511151 /**
1152- * Whether a member chain reads a property that is not defined.
1152+ * Finds the member of a chain that reads a property that is not defined.
11531153 * Walks the merged view so dotted keys of every instance count.
11541154 * Collects every define key consulted so the caller can record a
11551155 * value dependency on each (a sibling key like `OBJECT.SUB2` affects
@@ -1213,19 +1213,17 @@ class DefinePlugin {
12131213 } ) ;
12141214 // In a call, replace only the callee so the call itself is kept:
12151215 // `x.MISSING()` stays a (throwing) call and `x.MISSING?.()`
1216- // short-circuits, with the object never inlined.
1216+ // short-circuits, with the object never inlined. An optional link
1217+ // right after the undefined member short-circuits the whole call.
12171218 parser . hooks . callMemberChain
12181219 . for ( chainRoot )
12191220 . tap ( PLUGIN_NAME , ( expr , members , membersOptionals ) => {
12201221 const deps = [ key ] ;
12211222 const undefinedIndex = findUndefinedMemberAccess ( members , deps ) ;
12221223 if ( undefinedIndex === - 1 ) return ;
12231224 for ( const dep of deps ) addValueDependency ( dep ) ;
1224- for ( let i = undefinedIndex + 1 ; i < members . length ; i ++ ) {
1225- // an optional link after it short-circuits the whole call
1226- if ( membersOptionals [ i ] ) {
1227- return toConstantDependency ( parser , "undefined" ) ( expr ) ;
1228- }
1225+ if ( membersOptionals [ undefinedIndex + 1 ] ) {
1226+ return toConstantDependency ( parser , "undefined" ) ( expr ) ;
12291227 }
12301228 toConstantDependency (
12311229 parser ,
0 commit comments