Skip to content

Commit 4077894

Browse files
sokramischnic
authored andcommitted
omit empty source map when code starts with a new line
1 parent 2c3c12f commit 4077894

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

turbopack/crates/turbopack-core/src/code_builder.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,13 @@ impl Code {
187187
}
188188
last_byte_pos = *byte_pos;
189189

190-
if pos.column != 0 || map.is_some() {
191-
sections.push((pos, map.clone().unwrap_or_else(SourceMap::empty_rope)))
190+
if let Some(map) = map {
191+
sections.push((pos, map.clone()))
192+
} else {
193+
// We don't need an empty source map when column is 0 or the next char is a newline.
194+
if pos.column != 0 && read.fill_buf()?.first().is_some_and(|&b| b != b'\n') {
195+
sections.push((pos, SourceMap::empty_rope()));
196+
}
192197
}
193198
}
194199

0 commit comments

Comments
 (0)