diff --git a/src/dapp/libexec/dapp/dapp-remappings b/src/dapp/libexec/dapp/dapp-remappings index 0a1ea5a46..f1b16d390 100755 --- a/src/dapp/libexec/dapp/dapp-remappings +++ b/src/dapp/libexec/dapp/dapp-remappings @@ -52,7 +52,11 @@ function deduplicate(pkg) { // walk tree and build a mapping from hash => path function mapHashes(pkg) { const go = (mapping, dep) => { - mapping[dep.hash] = dep.path + // we collect the shortest path (aka closest to the root) for each dep + if (mapping[dep.hash] == undefined || dep.path.length < mapping[dep.hash].length) { + mapping[dep.hash] = dep.path + } + return dep.deps.reduce(go, mapping) } return pkg.deps.reduce(go, { [pkg.hash]: pkg.path })