Skip to content

Commit

Permalink
fix AliasMap debug format
Browse files Browse the repository at this point in the history
  • Loading branch information
ForsakenHarmony committed Jan 30, 2023
1 parent 4b9a9ab commit 3b6245a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions crates/next-core/src/next_server/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use turbo_tasks_fs::{glob::GlobVc, FileJsonContent, FileSystemPathVc};
use turbopack_core::resolve::{
find_context_file, package_json,
parse::RequestVc,
plugin::{ResolvePlugin, ResolvePluginConditionVc, ResolvePluginVc, ResolveResultOptionVc},
FindContextFileResult, ResolveResult, SpecialType,
plugin::{ResolvePlugin, ResolvePluginConditionVc, ResolvePluginVc},
FindContextFileResult, ResolveResult, ResolveResultOptionVc, SpecialType,
};

#[turbo_tasks::value]
Expand Down
18 changes: 13 additions & 5 deletions crates/turbopack-core/src/resolve/alias_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,25 @@ impl<T> ValueDebugFormat for AliasMap<T>
where
T: ValueDebugFormat,
{
fn value_debug_format(&self) -> ValueDebugFormatString {
fn value_debug_format(&self, depth: usize) -> ValueDebugFormatString {
if depth == 0 {
return ValueDebugFormatString::Sync(std::any::type_name::<Self>().to_string());
}

let values = self
.map
.iter()
.flat_map(|(key, map)| {
let key = String::from_utf8(key).expect("invalid UTF-8 key in AliasMap");
map.iter().map(move |(alias_key, value)| match alias_key {
AliasKey::Exact => (key.clone(), value.value_debug_format()),
AliasKey::Wildcard { suffix } => {
(format!("{}*{}", key, suffix), value.value_debug_format())
}
AliasKey::Exact => (
key.clone(),
value.value_debug_format(depth.saturating_sub(1)),
),
AliasKey::Wildcard { suffix } => (
format!("{}*{}", key, suffix),
value.value_debug_format(depth.saturating_sub(1)),
),
})
})
.collect::<Vec<_>>();
Expand Down

0 comments on commit 3b6245a

Please sign in to comment.