File tree 1 file changed +12
-3
lines changed
1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -121,7 +121,12 @@ export default class PackageLinker {
121
121
let checkParts = ownParts . slice ( 0 , i ) . concat ( pkg . name ) ;
122
122
let checkKey = checkParts . join ( "#" ) ;
123
123
let check = tree [ checkKey ] ;
124
- if ( check && check . loc === loc ) return [ ] ;
124
+ if ( check && check . loc === loc ) {
125
+ // we have a compatible module above us, we should mark the current
126
+ // module key as restricted and continue on
127
+ unflattenedKeys . add ( ownParts . concat ( pkg . name ) . join ( "#" ) ) ;
128
+ return [ ] ;
129
+ }
125
130
}
126
131
ownParts . push ( pkg . name ) ;
127
132
@@ -213,16 +218,20 @@ export default class PackageLinker {
213
218
tree [ newKey ] = info ;
214
219
pair [ 0 ] = newKey ;
215
220
216
- // go through and update all transitive dependencies and update to new hoisting position
221
+ // go through and update all transitive dependencies and update their keys to the new
222
+ // hoisting position
217
223
let pairs = subPairs . get ( info ) || [ ] ;
218
224
for ( let pair of pairs ) {
219
225
let [ subKey ] = pair ;
220
-
221
226
if ( subKey === newKey ) continue ;
222
227
223
228
let newSubKey = subKey . replace ( new RegExp ( `^${ oldKey } #` ) , `${ newKey } #` ) ;
224
229
if ( newSubKey === subKey ) continue ;
225
230
231
+ // restrict use of the new key in case we hoist it further from here
232
+ unflattenedKeys . add ( newSubKey ) ;
233
+
234
+ // update references
226
235
tree [ newSubKey ] = tree [ subKey ] ;
227
236
pair [ 0 ] = newSubKey ;
228
237
delete tree [ subKey ] ;
You can’t perform that action at this time.
0 commit comments