Skip to content

Commit

Permalink
Use source_root
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Jan 24, 2024
1 parent c3fd9d0 commit a570076
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/swc_common/src/source_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,7 @@ impl SourceMap {
// mappings.sort_by_key(|v| v.0);

let mut cur_file: Option<Lrc<SourceFile>> = None;
let mut source_root = None;

let mut prev_dst_line = u32::MAX;

Expand Down Expand Up @@ -1289,6 +1290,16 @@ impl SourceMap {
continue;
}

if source_root.is_none() {
if let FileName::Real(f) = &f.name {
if let Some(parent) = f.parent() {
let s = parent.display().to_string();
builder.set_source_root(Some(&s));
source_root = Some(s);
}
}
}

let emit_columns = config.emit_columns(&f.name);

if !emit_columns && lc.line == prev_dst_line {
Expand Down

0 comments on commit a570076

Please sign in to comment.