Skip to content

Sourcemap injection errors never displayed #2774

@szokeasaurusrex

Description

@szokeasaurusrex

Certain recoverable errors, occurring during the sourcemaps inject command, are never displayed to the user. Even though these errors are recoverable, they could well include information that is important to understanding why the command may not have had the desired effect, or which could generally indicate a problem.

This is one of the errors which would never be displayed:

source.warn(format!(
"could not determine a source map reference ({err})"
));

The reason is we store these errors on the SourceMapProcessor, but the inject report does not print these. It does not even appear to be aware of the struct the warnings are placed on

#[derive(Debug, Clone, Default)]
pub struct InjectReport {
pub injected: Vec<(PathBuf, DebugId)>,
pub previously_injected: Vec<(PathBuf, DebugId)>,
pub sourcemaps: Vec<(PathBuf, DebugId)>,
pub skipped_sourcemaps: Vec<(PathBuf, DebugId)>,
}
impl InjectReport {
pub fn is_empty(&self) -> bool {
self.injected.is_empty()
&& self.previously_injected.is_empty()
&& self.sourcemaps.is_empty()
&& self.skipped_sourcemaps.is_empty()
}
}
impl fmt::Display for InjectReport {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(
f,
"\n{}",
style("Source Map Debug ID Injection Report").dim().bold()
)?;
if !self.injected.is_empty() {
print_section_with_debugid(
f,
"Modified: The following source files have been modified to have debug ids",
&self.injected,
)?;
}
if !self.sourcemaps.is_empty() {
print_section_with_debugid(
f,
"Modified: The following sourcemap files have been modified to have debug ids",
&self.sourcemaps,
)?;
}
if !self.previously_injected.is_empty() {
print_section_with_debugid(
f,
"Ignored: The following source files already have debug ids",
&self.previously_injected,
)?;
}
if !self.skipped_sourcemaps.is_empty() {
print_section_with_debugid(
f,
"Ignored: The following sourcemap files already have debug ids",
&self.skipped_sourcemaps,
)?;
}
Ok(())
}
}

Metadata

Metadata

Labels

BugIssue typeCLIProduct area
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions