File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,7 @@ class SideEffectsFlagPlugin {
106106 for ( const pair of reexportMaps ) {
107107 const module = pair [ 0 ] ;
108108 const map = pair [ 1 ] ;
109+ let newReasons = undefined ;
109110 for ( let i = 0 ; i < module . reasons . length ; i ++ ) {
110111 const reason = module . reasons [ i ] ;
111112 const dep = reason . dependency ;
@@ -117,7 +118,6 @@ class SideEffectsFlagPlugin {
117118 if ( mapping ) {
118119 dep . redirectedModule = mapping . module ;
119120 dep . redirectedId = mapping . exportName ;
120- module . reasons . splice ( i -- , 1 ) ;
121121 mapping . module . addReason (
122122 reason . module ,
123123 dep ,
@@ -126,8 +126,18 @@ class SideEffectsFlagPlugin {
126126 " (skipped side-effect-free modules)"
127127 : "(skipped side-effect-free modules)"
128128 ) ;
129+ // removing the currect reason, by not adding it to the newReasons array
130+ // lazily create the newReasons array
131+ if ( newReasons === undefined ) {
132+ newReasons = i === 0 ? [ ] : module . reasons . slice ( 0 , i ) ;
133+ }
134+ continue ;
129135 }
130136 }
137+ if ( newReasons !== undefined ) newReasons . push ( reason ) ;
138+ }
139+ if ( newReasons !== undefined ) {
140+ module . reasons = newReasons ;
131141 }
132142 }
133143 }
You can’t perform that action at this time.
0 commit comments