@@ -295,32 +295,44 @@ export default class BundleGraph {
295
295
symbols . set ( from , existing ) ;
296
296
} else {
297
297
invariant ( isReexportAll ) ;
298
- let local = `${ node . value . id } $rewrite$${ asset } $${ from } ` ;
299
- symbols . set ( from , {
300
- isWeak : true ,
301
- local,
302
- loc : reexportAllLoc ,
303
- } ) ;
304
- // It might already exist with multiple export-alls causing ambiguous resolution
305
- if (
306
- node . value . sourceAssetId != null &&
307
- assetGraph . hasContentKey ( node . value . sourceAssetId )
308
- ) {
309
- let sourceAssetId = nullthrows (
310
- assetGraphNodeIdToBundleGraphNodeId . get (
311
- assetGraph . getNodeIdByContentKey (
312
- nullthrows ( node . value . sourceAssetId ) ,
298
+ if ( as === from ) {
299
+ // Keep the export-all for non-renamed reexports, this still correctly models
300
+ // ambiguous resolution with multiple export-alls.
301
+ symbols . set ( '*' , {
302
+ isWeak : true ,
303
+ local : '*' ,
304
+ loc : reexportAllLoc ,
305
+ } ) ;
306
+ } else {
307
+ let local = `${ node . value . id } $rewrite$${ asset } $${ from } ` ;
308
+ symbols . set ( from , {
309
+ isWeak : true ,
310
+ local,
311
+ loc : reexportAllLoc ,
312
+ } ) ;
313
+ if ( node . value . sourceAssetId != null ) {
314
+ let sourceAssetId = nullthrows (
315
+ assetGraphNodeIdToBundleGraphNodeId . get (
316
+ assetGraph . getNodeIdByContentKey (
317
+ node . value . sourceAssetId ,
318
+ ) ,
313
319
) ,
314
- ) ,
315
- ) ;
316
- let sourceAsset = nullthrows ( graph . getNode ( sourceAssetId ) ) ;
317
- invariant ( sourceAsset . type === 'asset' ) ;
318
- let sourceAssetSymbols = sourceAsset . value . symbols ;
319
- if ( sourceAssetSymbols && ! sourceAssetSymbols . has ( as ) ) {
320
- sourceAssetSymbols . set ( as , {
321
- loc : reexportAllLoc ,
322
- local : local ,
323
- } ) ;
320
+ ) ;
321
+ let sourceAsset = nullthrows (
322
+ graph . getNode ( sourceAssetId ) ,
323
+ ) ;
324
+ invariant ( sourceAsset . type === 'asset' ) ;
325
+ let sourceAssetSymbols = sourceAsset . value . symbols ;
326
+ if ( sourceAssetSymbols ) {
327
+ // The `as == from` case above should handle multiple export-alls causing
328
+ // ambiguous resolution. So the current symbol is unambiguous and shouldn't
329
+ // already exist on the importer.
330
+ invariant ( ! sourceAssetSymbols . has ( as ) ) ;
331
+ sourceAssetSymbols . set ( as , {
332
+ loc : reexportAllLoc ,
333
+ local : local ,
334
+ } ) ;
335
+ }
324
336
}
325
337
}
326
338
}
@@ -342,7 +354,7 @@ export default class BundleGraph {
342
354
} ,
343
355
usedSymbolsUp,
344
356
// This is only a temporary helper needed during symbol propagation and is never
345
- // read afterwards.
357
+ // read afterwards (and also not exposed through the public API) .
346
358
usedSymbolsDown : new Set ( ) ,
347
359
} ) ,
348
360
} ;
0 commit comments