Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packager request #6379

Merged
merged 17 commits into from Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -1458,7 +1450,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),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Target options aren't in the environment hash and aren't tracked in the graph. This is kinda assuming that packagers will use the publicUrl in some way, but currently this is only true of the HTML packager. Perhaps we can make this more granular in the future somehow...

);

let inlineBundles = this.getInlineBundles(bundle);
for (let inlineBundle of inlineBundles) {
Expand All @@ -1475,6 +1469,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