@parcel/core
Advanced tools
Comparing version 2.0.0-nightly.234 to 2.0.0-nightly.237
@@ -117,3 +117,3 @@ "use strict"; | ||
for (let asset of assets) { | ||
if (bundleGraph.isAssetInAncestorBundles(bundle, asset)) { | ||
if (bundleGraph.isAssetReachableFromBundle(asset, bundle)) { | ||
duplicatedAssetIds.add(asset.id); | ||
@@ -120,0 +120,0 @@ actions.skipChildren(); |
@@ -317,28 +317,39 @@ "use strict"; | ||
isAssetInAncestorBundles(bundle, asset) { | ||
let parentBundleNodes = (0, _utils.flatMap)(this._graph.getNodesConnectedTo((0, _nullthrows.default)(this._graph.getNode(bundle.id)), 'bundle'), bundleGroupNode => { | ||
(0, _assert.default)(bundleGroupNode.type === 'bundle_group'); | ||
return this._graph.getNodesConnectedTo(bundleGroupNode, 'bundle'); | ||
}); | ||
return parentBundleNodes.every(parentNode => { | ||
let inBundle; | ||
isAssetReachableFromBundle(asset, bundle) { | ||
// For an asset to be reachable from a bundle, it must either exist in a sibling bundle, | ||
// or in an ancestor bundle group reachable from all parent bundles. | ||
let bundleGroups = this.getBundleGroupsContainingBundle(bundle); | ||
return bundleGroups.every(bundleGroup => { | ||
// If the asset is in any sibling bundles of the original bundle, it is reachable. | ||
let bundles = this.getBundlesInBundleGroup(bundleGroup); | ||
this._graph.traverseAncestors(parentNode, (node, ctx, actions) => { | ||
if (node.type !== 'bundle' || node.id === bundle.id) { | ||
return; | ||
} // Don't deduplicate when context changes | ||
if (bundles.some(b => b.id !== bundle.id && this.bundleHasAsset(b, asset))) { | ||
return true; | ||
} // Get a list of parent bundle nodes pointing to the bundle group | ||
if (node.value.env.context !== bundle.env.context) { | ||
actions.skipChildren(); | ||
return; | ||
} | ||
let parentBundleNodes = this._graph.getNodesConnectedTo((0, _nullthrows.default)(this._graph.getNode((0, _utils2.getBundleGroupId)(bundleGroup))), 'bundle'); // Check that every parent bundle has a bundle group in its ancestry that contains the asset. | ||
if (this._graph.hasEdge(node.value.id, asset.id, 'contains')) { | ||
inBundle = true; | ||
actions.stop(); | ||
} | ||
}, 'bundle'); | ||
return inBundle; | ||
return parentBundleNodes.every(bundleNode => { | ||
let inBundle = false; | ||
this._graph.traverseAncestors(bundleNode, (node, ctx, actions) => { | ||
if (node.type === 'bundle_group') { | ||
let childBundles = this.getBundlesInBundleGroup(node.value); | ||
if (childBundles.some(b => b.id !== bundle.id && this.bundleHasAsset(b, asset))) { | ||
inBundle = true; | ||
actions.stop(); | ||
} | ||
} // Don't deduplicate when context changes | ||
if (node.type === 'bundle' && node.value.env.context !== bundle.env.context) { | ||
actions.skipChildren(); | ||
} | ||
}, 'bundle'); | ||
return inBundle; | ||
}); | ||
}); | ||
@@ -345,0 +356,0 @@ } |
@@ -114,7 +114,7 @@ "use strict"; | ||
isAssetInAncestorBundles(bundle, asset) { | ||
isAssetReachableFromBundle(asset, bundle) { | ||
let internalNode = _classPrivateFieldGet(this, _graph)._graph.getNode(bundle.id); | ||
(0, _assert.default)(internalNode != null && internalNode.type === 'bundle'); | ||
return _classPrivateFieldGet(this, _graph).isAssetInAncestorBundles(internalNode.value, (0, _Asset.assetToAssetValue)(asset)); | ||
return _classPrivateFieldGet(this, _graph).isAssetReachableFromBundle((0, _Asset.assetToAssetValue)(asset), internalNode.value); | ||
} | ||
@@ -121,0 +121,0 @@ |
@@ -244,4 +244,4 @@ "use strict"; | ||
isAssetInAncestorBundles(bundle, asset) { | ||
return _classPrivateFieldGet(this, _graph).isAssetInAncestorBundles((0, _Bundle.bundleToInternalBundle)(bundle), (0, _Asset.assetToAssetValue)(asset)); | ||
isAssetReachableFromBundle(asset, bundle) { | ||
return _classPrivateFieldGet(this, _graph).isAssetReachableFromBundle((0, _Asset.assetToAssetValue)(asset), (0, _Bundle.bundleToInternalBundle)(bundle)); | ||
} | ||
@@ -248,0 +248,0 @@ |
{ | ||
"name": "@parcel/core", | ||
"version": "2.0.0-nightly.234+297087a8", | ||
"version": "2.0.0-nightly.237+df509222", | ||
"license": "MIT", | ||
@@ -19,13 +19,13 @@ "publishConfig": { | ||
"dependencies": { | ||
"@parcel/cache": "2.0.0-nightly.236+297087a8", | ||
"@parcel/diagnostic": "2.0.0-nightly.236+297087a8", | ||
"@parcel/events": "2.0.0-nightly.236+297087a8", | ||
"@parcel/fs": "2.0.0-nightly.236+297087a8", | ||
"@parcel/logger": "2.0.0-nightly.236+297087a8", | ||
"@parcel/package-manager": "2.0.0-nightly.236+297087a8", | ||
"@parcel/plugin": "2.0.0-nightly.236+297087a8", | ||
"@parcel/cache": "2.0.0-nightly.239+df509222", | ||
"@parcel/diagnostic": "2.0.0-nightly.239+df509222", | ||
"@parcel/events": "2.0.0-nightly.239+df509222", | ||
"@parcel/fs": "2.0.0-nightly.239+df509222", | ||
"@parcel/logger": "2.0.0-nightly.239+df509222", | ||
"@parcel/package-manager": "2.0.0-nightly.239+df509222", | ||
"@parcel/plugin": "2.0.0-nightly.239+df509222", | ||
"@parcel/source-map": "2.0.0-alpha.4.9", | ||
"@parcel/types": "2.0.0-nightly.236+297087a8", | ||
"@parcel/utils": "2.0.0-nightly.236+297087a8", | ||
"@parcel/workers": "2.0.0-nightly.236+297087a8", | ||
"@parcel/types": "2.0.0-nightly.239+df509222", | ||
"@parcel/utils": "2.0.0-nightly.239+df509222", | ||
"@parcel/workers": "2.0.0-nightly.239+df509222", | ||
"abortcontroller-polyfill": "^1.1.9", | ||
@@ -46,3 +46,3 @@ "browserslist": "^4.6.6", | ||
}, | ||
"gitHead": "297087a806f9ed958fad1e2217d735b284cd3d5c" | ||
"gitHead": "df509222e6808e49009e77bff8f4f9bdc94865bc" | ||
} |
@@ -118,3 +118,3 @@ // @flow strict-local | ||
for (let asset of assets) { | ||
if (bundleGraph.isAssetInAncestorBundles(bundle, asset)) { | ||
if (bundleGraph.isAssetReachableFromBundle(asset, bundle)) { | ||
duplicatedAssetIds.add(asset.id); | ||
@@ -121,0 +121,0 @@ actions.skipChildren(); |
@@ -430,39 +430,53 @@ // @flow strict-local | ||
isAssetInAncestorBundles(bundle: Bundle, asset: Asset): boolean { | ||
let parentBundleNodes = flatMap( | ||
this._graph.getNodesConnectedTo( | ||
nullthrows(this._graph.getNode(bundle.id)), | ||
isAssetReachableFromBundle(asset: Asset, bundle: Bundle): boolean { | ||
// For an asset to be reachable from a bundle, it must either exist in a sibling bundle, | ||
// or in an ancestor bundle group reachable from all parent bundles. | ||
let bundleGroups = this.getBundleGroupsContainingBundle(bundle); | ||
return bundleGroups.every(bundleGroup => { | ||
// If the asset is in any sibling bundles of the original bundle, it is reachable. | ||
let bundles = this.getBundlesInBundleGroup(bundleGroup); | ||
if ( | ||
bundles.some(b => b.id !== bundle.id && this.bundleHasAsset(b, asset)) | ||
) { | ||
return true; | ||
} | ||
// Get a list of parent bundle nodes pointing to the bundle group | ||
let parentBundleNodes = this._graph.getNodesConnectedTo( | ||
nullthrows(this._graph.getNode(getBundleGroupId(bundleGroup))), | ||
'bundle', | ||
), | ||
bundleGroupNode => { | ||
invariant(bundleGroupNode.type === 'bundle_group'); | ||
return this._graph.getNodesConnectedTo(bundleGroupNode, 'bundle'); | ||
}, | ||
); | ||
); | ||
return parentBundleNodes.every(parentNode => { | ||
let inBundle; | ||
// Check that every parent bundle has a bundle group in its ancestry that contains the asset. | ||
return parentBundleNodes.every(bundleNode => { | ||
let inBundle = false; | ||
this._graph.traverseAncestors( | ||
parentNode, | ||
(node, ctx, actions) => { | ||
if (node.type !== 'bundle' || node.id === bundle.id) { | ||
return; | ||
} | ||
this._graph.traverseAncestors( | ||
bundleNode, | ||
(node, ctx, actions) => { | ||
if (node.type === 'bundle_group') { | ||
let childBundles = this.getBundlesInBundleGroup(node.value); | ||
if ( | ||
childBundles.some( | ||
b => b.id !== bundle.id && this.bundleHasAsset(b, asset), | ||
) | ||
) { | ||
inBundle = true; | ||
actions.stop(); | ||
} | ||
} | ||
// Don't deduplicate when context changes | ||
if (node.value.env.context !== bundle.env.context) { | ||
actions.skipChildren(); | ||
return; | ||
} | ||
// Don't deduplicate when context changes | ||
if ( | ||
node.type === 'bundle' && | ||
node.value.env.context !== bundle.env.context | ||
) { | ||
actions.skipChildren(); | ||
} | ||
}, | ||
'bundle', | ||
); | ||
if (this._graph.hasEdge(node.value.id, asset.id, 'contains')) { | ||
inBundle = true; | ||
actions.stop(); | ||
} | ||
}, | ||
'bundle', | ||
); | ||
return inBundle; | ||
return inBundle; | ||
}); | ||
}); | ||
@@ -469,0 +483,0 @@ } |
@@ -121,8 +121,8 @@ // @flow strict-local | ||
isAssetInAncestorBundles(bundle: IBundle, asset: IAsset): boolean { | ||
isAssetReachableFromBundle(asset: IAsset, bundle: IBundle): boolean { | ||
let internalNode = this.#graph._graph.getNode(bundle.id); | ||
invariant(internalNode != null && internalNode.type === 'bundle'); | ||
return this.#graph.isAssetInAncestorBundles( | ||
return this.#graph.isAssetReachableFromBundle( | ||
assetToAssetValue(asset), | ||
internalNode.value, | ||
assetToAssetValue(asset), | ||
); | ||
@@ -129,0 +129,0 @@ } |
@@ -261,6 +261,6 @@ // @flow strict-local | ||
isAssetInAncestorBundles(bundle: IBundle, asset: IAsset): boolean { | ||
return this.#graph.isAssetInAncestorBundles( | ||
isAssetReachableFromBundle(asset: IAsset, bundle: IBundle): boolean { | ||
return this.#graph.isAssetReachableFromBundle( | ||
assetToAssetValue(asset), | ||
bundleToInternalBundle(bundle), | ||
assetToAssetValue(asset), | ||
); | ||
@@ -267,0 +267,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
704537
20618