Skip to content

Commit

Permalink
Merged in wbinnssmith/stop-removing-graph (pull request #4)
Browse files Browse the repository at this point in the history
Stop removing subgraphs at bundle boundaries

Approved-by: Maia Teegarden
  • Loading branch information
Will Binns-Smith committed Sep 24, 2019
2 parents d6cebc2 + dc2c020 commit de795cb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
5 changes: 4 additions & 1 deletion packages/bundlers/default/src/DefaultBundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ export default new Bundler({
let assets = bundleGraph.getDependencyAssets(dependency);

for (let asset of assets) {
if (bundleGraph.isAssetInAncestorBundles(bundle, asset)) {
if (
bundle.hasAsset(asset) &&
bundleGraph.isAssetInAncestorBundles(bundle, asset)
) {
bundleGraph.removeAssetGraphFromBundle(asset, bundle);
}
}
Expand Down
16 changes: 10 additions & 6 deletions packages/core/core/src/BundleGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,14 @@ export default class BundleGraph {

removeAssetGraphFromBundle(asset: Asset, bundle: Bundle) {
this._graph.removeEdge(bundle.id, asset.id);
this._graph.traverse(node => {
if (node.type === 'asset' || node.type === 'dependency') {
this.traverseBundle(
bundle,
node => {
this._graph.removeEdge(bundle.id, node.id, 'contains');
}
}, nullthrows(this._graph.getNode(asset.id)));
},
false,
nullthrows(this._graph.getNode(asset.id))
);
}

createAssetReference(dependency: Dependency, asset: Asset): void {
Expand Down Expand Up @@ -388,7 +391,8 @@ export default class BundleGraph {
traverseBundle<TContext>(
bundle: Bundle,
visit: GraphVisitor<AssetNode | DependencyNode, TContext>,
includeAll: boolean = false
includeAll: boolean = false,
startNode?: BundleGraphNode
): ?TContext {
return this._graph.filteredTraverse(
(node, actions) => {
Expand All @@ -408,7 +412,7 @@ export default class BundleGraph {
actions.skipChildren();
},
visit,
nullthrows(this._graph.getNode(bundle.id))
startNode ?? nullthrows(this._graph.getNode(bundle.id))
);
}

Expand Down

0 comments on commit de795cb

Please sign in to comment.