From 245611b75849d1525f355804ac5c4d78904b618f Mon Sep 17 00:00:00 2001 From: mattcompiles Date: Wed, 8 May 2024 15:34:33 +1000 Subject: [PATCH] Ensure Asset public ids are assigned deterministically --- packages/core/core/src/BundleGraph.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/core/core/src/BundleGraph.js b/packages/core/core/src/BundleGraph.js index 350a6bf73f8f..88cbfb9f6460 100644 --- a/packages/core/core/src/BundleGraph.js +++ b/packages/core/core/src/BundleGraph.js @@ -174,7 +174,9 @@ export default class BundleGraph { : null; invariant(assetGraphRootNode != null && assetGraphRootNode.type === 'root'); - for (let [nodeId, node] of assetGraph.nodes.entries()) { + assetGraph.dfsFast(nodeId => { + let node = assetGraph.getNode(nodeId); + if (node != null && node.type === 'asset') { let {id: assetId} = node.value; // Generate a new, short public id for this asset to use. @@ -190,7 +192,7 @@ export default class BundleGraph { } else if (node != null && node.type === 'asset_group') { assetGroupIds.set(nodeId, assetGraph.getNodeIdsConnectedFrom(nodeId)); } - } + }); let walkVisited = new Set(); function walk(nodeId) {