Skip to content

Commit

Permalink
Add bundle.mainEntryAsset
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Binns-Smith committed May 3, 2022
1 parent e5c4c8a commit 836fac2
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions packages/bundlers/experimental/src/ExperimentalBundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export type Bundle = {|
internalizedAssetIds: Array<AssetId>,
bundleBehavior?: ?BundleBehavior,
needsStableName: boolean,
mainEntryAsset: ?Asset,
size: number,
sourceBundles: Array<NodeId>,
target: Target,
Expand Down Expand Up @@ -118,7 +119,7 @@ function decorateLegacyGraph(
// Step 1: Create bundle groups, bundles, and shared bundles and add assets to them
for (let [bundleNodeId, idealBundle] of idealBundleGraph.nodes) {
if (idealBundle === 'root') continue;
let [entryAsset] = [...idealBundle.assets];
let entryAsset = idealBundle.mainEntryAsset;
let bundleGroup;
let bundle;

Expand Down Expand Up @@ -645,16 +646,18 @@ function createIdealGraph(
) {
continue;
}
let [siblingBundleRoot] = [...bundleInGroup.assets];
// Assets directly connected to current bundleRoot
let assetsFromBundleRoot = reachableRoots
.getNodeIdsConnectedFrom(
reachableRoots.getNodeIdByContentKey(siblingBundleRoot.id),
)
.map(id => nullthrows(reachableRoots.getNode(id)));

for (let asset of [siblingBundleRoot, ...assetsFromBundleRoot]) {
available.add(asset);

for (let bundleRoot of bundleInGroup.assets) {
// Assets directly connected to current bundleRoot
let assetsFromBundleRoot = reachableRoots
.getNodeIdsConnectedFrom(
reachableRoots.getNodeIdByContentKey(bundleRoot.id),
)
.map(id => nullthrows(reachableRoots.getNode(id)));

for (let asset of [bundleRoot, ...assetsFromBundleRoot]) {
available.add(asset);
}
}
}
}
Expand Down Expand Up @@ -824,6 +827,7 @@ function createBundle(opts: {|
uniqueKey: opts.uniqueKey,
assets: new Set(),
internalizedAssetIds: [],
mainEntryAsset: null,
size: 0,
sourceBundles: [],
target: opts.target,
Expand All @@ -839,6 +843,7 @@ function createBundle(opts: {|
uniqueKey: opts.uniqueKey,
assets: new Set([asset]),
internalizedAssetIds: [],
mainEntryAsset: asset,
size: asset.stats.size,
sourceBundles: [],
target: opts.target,
Expand Down

0 comments on commit 836fac2

Please sign in to comment.