fix: only notify about unresolved import once (#1125)

This commit is contained in:
Matthias Seitz 2022-04-08 16:37:43 +02:00 committed by GitHub
parent e394f40e46
commit 69bf6ddd0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

View File

@ -318,6 +318,11 @@ impl Graph {
// contains the files and their dependencies // contains the files and their dependencies
let mut nodes = Vec::with_capacity(unresolved.len()); let mut nodes = Vec::with_capacity(unresolved.len());
let mut edges = Vec::with_capacity(unresolved.len()); let mut edges = Vec::with_capacity(unresolved.len());
// keep track of all unique paths that we failed to resolve to not spam the reporter with
// the same path
let mut unresolved_paths = HashSet::new();
// now we need to resolve all imports for the source file and those imported from other // now we need to resolve all imports for the source file and those imported from other
// locations // locations
while let Some((path, node)) = unresolved.pop_front() { while let Some((path, node)) = unresolved.pop_front() {
@ -334,11 +339,18 @@ impl Graph {
add_node(&mut unresolved, &mut index, &mut resolved_imports, import)?; add_node(&mut unresolved, &mut index, &mut resolved_imports, import)?;
} }
Err(err) => { Err(err) => {
if unresolved_paths.insert(import.data().to_path_buf()) {
crate::report::unresolved_import(import.data(), &paths.remappings); crate::report::unresolved_import(import.data(), &paths.remappings);
tracing::trace!("failed to resolve import component \"{:?}\"", err) }
tracing::trace!(
"failed to resolve import component \"{:?}\" for {:?}",
err,
node.path
)
} }
}; };
} }
nodes.push(node); nodes.push(node);
edges.push(resolved_imports); edges.push(resolved_imports);
} }