fix: correctly override dependencies

This commit is contained in:
daimond113 2024-12-04 01:09:57 +01:00
parent f7d2d7cbb0
commit 7b592bb719
No known key found for this signature in database
GPG key ID: 3A8ECE51328B513C
2 changed files with 17 additions and 9 deletions

View file

@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- Link dependencies before type extraction to support more use cases by @daimond113 - 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 - 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 ## [0.5.0-rc.14] - 2024-11-30
### Fixed ### Fixed

View file

@ -119,7 +119,6 @@ impl Project {
.into_iter() .into_iter()
.map(|((spec, ty), alias)| { .map(|((spec, ty), alias)| {
( (
alias.to_string(),
spec, spec,
ty, ty,
None::<(PackageNames, VersionId)>, None::<(PackageNames, VersionId)>,
@ -130,14 +129,16 @@ impl Project {
}) })
.collect::<VecDeque<_>>(); .collect::<VecDeque<_>>();
while let Some((alias, specifier, ty, dependant, path, overridden, target)) = while let Some((specifier, ty, dependant, path, overridden, target)) =
queue.pop_front() queue.pop_front()
{ {
let alias = path.last().unwrap().clone();
let depth = path.len() - 1; let depth = path.len() - 1;
log::debug!( log::debug!(
"{}resolving {specifier} ({alias}) from {dependant:?}", "{}resolving {specifier} from {}",
"\t".repeat(depth) "\t".repeat(depth),
path.join(">")
); );
let source = match &specifier { let source = match &specifier {
DependencySpecifiers::Pesde(specifier) => { DependencySpecifiers::Pesde(specifier) => {
@ -255,7 +256,8 @@ impl Project {
!= std::mem::discriminant(pkg_ref) != std::mem::discriminant(pkg_ref)
{ {
log::warn!( 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() { if overridden.is_some() {
log::debug!( log::debug!(
"{}overridden specifier found for {dependency_alias} ({dependency_spec})", "{}overridden specifier found for {} ({dependency_spec})",
"\t".repeat(depth) "\t".repeat(depth),
path
.iter()
.map(|s| s.as_str())
.chain(std::iter::once(dependency_alias.as_str()))
.collect::<Vec<_>>()
.join(">"),
); );
} }
queue.push_back(( queue.push_back((
dependency_alias,
overridden.cloned().unwrap_or(dependency_spec), overridden.cloned().unwrap_or(dependency_spec),
dependency_ty, dependency_ty,
Some((name.clone(), target_version_id.clone())), Some((name.clone(), target_version_id.clone())),
path.iter() path.iter()
.cloned() .cloned()
.chain(std::iter::once(alias.to_string())) .chain(std::iter::once(dependency_alias))
.collect(), .collect(),
overridden.is_some(), overridden.is_some(),
*target_version_id.target(), *target_version_id.target(),