Skip to content

Commit

Permalink
Packager request (#6379)
Browse files Browse the repository at this point in the history
  • Loading branch information
devongovett committed Jun 10, 2021
1 parent 207f198 commit 1ba0bd1
Show file tree
Hide file tree
Showing 27 changed files with 1,910 additions and 581 deletions.
23 changes: 13 additions & 10 deletions packages/core/core/src/BundleGraph.js
Expand Up @@ -24,7 +24,7 @@ import assert from 'assert';
import invariant from 'assert';
import nullthrows from 'nullthrows';
import {objectSortedEntriesDeep} from '@parcel/utils';
import {Hash} from '@parcel/hash';
import {Hash, hashString} from '@parcel/hash';

import {getBundleGroupId, getPublicId} from './utils';
import {ALL_EDGE_TYPES, mapVisitor} from './Graph';
Expand Down Expand Up @@ -234,10 +234,6 @@ export default class BundleGraph {
return;
}

if (node.type === 'asset' && !this.bundleHasAsset(bundle, node.value)) {
bundle.stats.size += node.value.stats.size;
}

if (node.type === 'asset' || node.type === 'dependency') {
this._graph.addEdge(bundleNodeId, nodeId, 'contains');
}
Expand Down Expand Up @@ -432,10 +428,6 @@ export default class BundleGraph {
// aggregate.
false /* removeOrphans */,
);

if (node.type === 'asset') {
bundle.stats.size -= asset.stats.size;
}
} else {
actions.skipChildren();
}
Expand Down Expand Up @@ -1466,7 +1458,9 @@ export default class BundleGraph {

getHash(bundle: Bundle): string {
let hash = new Hash();
hash.writeString(bundle.id + this.getContentHash(bundle));
hash.writeString(
bundle.id + bundle.target.publicUrl + this.getContentHash(bundle),
);

let inlineBundles = this.getInlineBundles(bundle);
for (let inlineBundle of inlineBundles) {
Expand All @@ -1483,6 +1477,15 @@ export default class BundleGraph {
return hash.finish();
}

getBundleGraphHash(): string {
let hashes = '';
for (let bundle of this.getBundles()) {
hashes += this.getHash(bundle);
}

return hashString(hashes);
}

addBundleToBundleGroup(bundle: Bundle, bundleGroup: BundleGroup) {
let bundleGroupNodeId = this._graph.getNodeIdByContentKey(
getBundleGroupId(bundleGroup),
Expand Down

0 comments on commit 1ba0bd1

Please sign in to comment.