Skip to content

Commit

Permalink
Copy over the whole node in incremental
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Mar 1, 2023
1 parent af58fc1 commit 5ad82aa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
10 changes: 3 additions & 7 deletions packages/core/core/src/BundleGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import type {
} from './types';
import type AssetGraph from './AssetGraph';
import type {ProjectPath} from './projectPath';
import {nodeFromAsset} from './AssetGraph';

import assert from 'assert';
import invariant from 'assert';
Expand Down Expand Up @@ -2064,12 +2063,9 @@ export default class BundleGraph {
/**
* Update the asset in a Bundle Graph and clear the associated Bundle hash.
*/
updateAsset(asset: Asset) {
this._graph.updateNode(
this._graph.getNodeIdByContentKey(asset.id),
nodeFromAsset(asset),
);
let bundles = this.getBundlesWithAsset(asset);
updateAsset(asset: AssetNode) {
this._graph.updateNode(this._graph.getNodeIdByContentKey(asset.id), asset);
let bundles = this.getBundlesWithAsset(asset.value);
for (let bundle of bundles) {
// the bundle content will change with a modified asset
this._bundleContentHashes.delete(bundle.id);
Expand Down
9 changes: 7 additions & 2 deletions packages/core/core/src/requests/BundleGraphRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,13 @@ class BundlerRunner {
try {
if (previousBundleGraphResult) {
internalBundleGraph = previousBundleGraphResult.bundleGraph;
for (let changedAsset of changedAssets.values()) {
internalBundleGraph.updateAsset(changedAsset);
for (let changedAssetId of changedAssets.keys()) {
// Copy over the whole node to also have correct symbol data
let changedAssetNode = nullthrows(
graph.getNodeByContentKey(changedAssetId),
);
invariant(changedAssetNode.type === 'asset');
internalBundleGraph.updateAsset(changedAssetNode);
}
} else {
internalBundleGraph = InternalBundleGraph.fromAssetGraph(
Expand Down

0 comments on commit 5ad82aa

Please sign in to comment.