@@ -1444,13 +1444,13 @@ export default class BundleGraph {
14441444
14451445 this . traverseAssets ( bundle , ( asset ) => {
14461446 // Quick check 1: If asset is in multiple bundles in same target, it's referenced
1447- if (
1448- this . getBundlesWithAsset ( asset ) . filter (
1449- ( b ) =>
1450- b . target . name === bundle . target . name &&
1451- b . target . distDir === bundle . target . distDir ,
1452- ) . length > 1
1453- ) {
1447+ let bundlesWithAsset = this . getBundlesWithAsset ( asset ) . filter (
1448+ ( b ) =>
1449+ b . target . name === bundle . target . name &&
1450+ b . target . distDir === bundle . target . distDir ,
1451+ ) ;
1452+
1453+ if ( bundlesWithAsset . length > 1 ) {
14541454 referencedAssets . add ( asset ) ;
14551455 return ;
14561456 }
@@ -1495,13 +1495,15 @@ export default class BundleGraph {
14951495 }
14961496
14971497 // Now do ONE traversal to check all remaining assets
1498- let visitedBundles : Set < Bundle > = new Set ( ) ;
14991498 let siblingBundles = new Set (
15001499 this . getBundleGroupsContainingBundle ( bundle ) . flatMap ( ( bundleGroup ) =>
15011500 this . getBundlesInBundleGroup ( bundleGroup , { includeInline : true } ) ,
15021501 ) ,
15031502 ) ;
15041503
1504+ // Track visited bundles across all sibling traversals (matching original implementation)
1505+ let visitedBundles : Set < Bundle > = new Set ( ) ;
1506+
15051507 // Check if any of this bundle's descendants reference any of our assets
15061508 for ( let referencer of siblingBundles ) {
15071509 this . traverseBundles ( ( descendant , _ , actions ) => {
@@ -1521,7 +1523,7 @@ export default class BundleGraph {
15211523 fromEnvironmentId ( descendant . env ) . context !==
15221524 fromEnvironmentId ( bundle . env ) . context
15231525 ) {
1524- actions . skipChildren ( ) ;
1526+ // Don't skip children - they might be the right type!
15251527 return ;
15261528 }
15271529
0 commit comments