Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
AGawrys committed Jun 1, 2022
1 parent 0226dc4 commit 0c3a653
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 25 deletions.
33 changes: 9 additions & 24 deletions packages/bundlers/experimental/src/ExperimentalBundler.js
Expand Up @@ -283,7 +283,7 @@ function decorateLegacyGraph(
function createIdealGraph(
assetGraph: MutableBundleGraph,
config: ResolvedBundlerConfig,
selectedEntries: Set<Asset>,
entries: Map<Asset, Dependency>,
): IdealGraph {
// Asset to the bundle and group it's an entry of
let bundleRoots: Map<BundleRoot, [NodeId, NodeId]> = new Map();
Expand Down Expand Up @@ -312,31 +312,13 @@ function createIdealGraph(
// Models bundleRoots and the assets that require it synchronously
let reachableRoots: ContentGraph<Asset> = new ContentGraph();
// Step Create Entry Bundles: Find and create bundles for entries from assetGraph
let entries: Map<Asset, Dependency> = new Map();
let sharedToSourceBundleIds: Map<NodeId, Array<NodeId>> = new Map();
assetGraph.traverse((node, context, actions) => {
if (node.type !== 'asset') {
return node;
}
if (!selectedEntries.has(node.value)) {
actions.skipChildren(); //this can be replaced with selected entries if we store dependency in target map and pass in with selected entries
return node;
}

invariant(
context != null && context.type === 'dependency' && context.value.isEntry,
);
entries.set(node.value, context.value);
actions.skipChildren();
});

let rootNodeId = nullthrows(asyncBundleRootGraph.addNode('root'));
let bundleGraphRootNodeId = nullthrows(bundleGraph.addNode('root'));
asyncBundleRootGraph.setRootNodeId(rootNodeId);
bundleGraph.setRootNodeId(bundleGraphRootNodeId);

// Step Create Entry Bundles
for (let [asset, dependency] of entries) {
let bundle = createBundle({
asset,
Expand Down Expand Up @@ -377,7 +359,7 @@ function createIdealGraph(
if (
context?.type === 'dependency' &&
context?.value.isEntry &&
!selectedEntries.has(node.value)
!entries.has(node.value)
) {
actions.skipChildren();
return node;
Expand Down Expand Up @@ -1151,8 +1133,11 @@ function getReachableBundleRoots(asset, graph): Array<BundleRoot> {

function getEntryByTarget(
bundleGraph: MutableBundleGraph,
): DefaultMap<string, Set<Asset>> {
let targets: DefaultMap<string, Set<Asset>> = new DefaultMap(() => new Set());
): DefaultMap<string, Map<Asset, Dependency>> {
// Find entries from assetGraph per target
let targets: DefaultMap<string, Map<Asset, Dependency>> = new DefaultMap(
() => new Map(),
);
bundleGraph.traverse({
enter(node, context, actions) {
if (node.type !== 'asset') {
Expand All @@ -1164,7 +1149,7 @@ function getEntryByTarget(
context.value.isEntry &&
context.value.target != null,
);
targets.get(context.value.target.distDir).add(node.value);
targets.get(context.value.target.distDir).set(node.value, context.value);
actions.skipChildren();
return node;
},
Expand Down
1 change: 0 additions & 1 deletion packages/core/core/src/BundleGraph.js
Expand Up @@ -1312,7 +1312,6 @@ export default class BundleGraph {
nodeId,
bundleGraphEdgeTypes.references,
),
//.reverse(),
});

return [...referencedBundles];
Expand Down

0 comments on commit 0c3a653

Please sign in to comment.