From 7b592bb7196b5491f20c4f560d5f3c31f48c8b01 Mon Sep 17 00:00:00 2001 From: daimond113 <72147841+daimond113@users.noreply.github.com> Date: Wed, 4 Dec 2024 01:09:57 +0100 Subject: [PATCH] fix: correctly override dependencies --- CHANGELOG.md | 1 + src/resolver.rs | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7492a2b..4360b29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Link dependencies before type extraction to support more use cases by @daimond113 - Strip `.luau` extension from linker modules' require paths to comply with Luau by @daimond113 +- Correctly handle graph paths for resolving overriden packages by @daimond113 ## [0.5.0-rc.14] - 2024-11-30 ### Fixed diff --git a/src/resolver.rs b/src/resolver.rs index 0d8ef8d..6a67c57 100644 --- a/src/resolver.rs +++ b/src/resolver.rs @@ -119,7 +119,6 @@ impl Project { .into_iter() .map(|((spec, ty), alias)| { ( - alias.to_string(), spec, ty, None::<(PackageNames, VersionId)>, @@ -130,14 +129,16 @@ impl Project { }) .collect::>(); - while let Some((alias, specifier, ty, dependant, path, overridden, target)) = + while let Some((specifier, ty, dependant, path, overridden, target)) = queue.pop_front() { + let alias = path.last().unwrap().clone(); let depth = path.len() - 1; log::debug!( - "{}resolving {specifier} ({alias}) from {dependant:?}", - "\t".repeat(depth) + "{}resolving {specifier} from {}", + "\t".repeat(depth), + path.join(">") ); let source = match &specifier { DependencySpecifiers::Pesde(specifier) => { @@ -255,7 +256,8 @@ impl Project { != std::mem::discriminant(pkg_ref) { log::warn!( - "resolved package {name}@{target_version_id} has a different source than the previously resolved one, this may cause issues", + "resolved package {name}@{target_version_id} has a different source than the previously resolved one at {}, this may cause issues", + path.join(">") ); } @@ -319,19 +321,24 @@ impl Project { if overridden.is_some() { log::debug!( - "{}overridden specifier found for {dependency_alias} ({dependency_spec})", - "\t".repeat(depth) + "{}overridden specifier found for {} ({dependency_spec})", + "\t".repeat(depth), + path + .iter() + .map(|s| s.as_str()) + .chain(std::iter::once(dependency_alias.as_str())) + .collect::>() + .join(">"), ); } queue.push_back(( - dependency_alias, overridden.cloned().unwrap_or(dependency_spec), dependency_ty, Some((name.clone(), target_version_id.clone())), path.iter() .cloned() - .chain(std::iter::once(alias.to_string())) + .chain(std::iter::once(dependency_alias)) .collect(), overridden.is_some(), *target_version_id.target(),