Skip to content

Commit a847aae

Browse files
authored
feat: Add support for sourcemap debugid property (#151)
1 parent 10b6a4c commit a847aae

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/source.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ pub struct SourceMap {
206206
mappings: Arc<str>,
207207
#[serde(rename = "sourceRoot", skip_serializing_if = "Option::is_none")]
208208
source_root: Option<Arc<str>>,
209+
#[serde(rename = "debugId", skip_serializing_if = "Option::is_none")]
210+
debug_id: Option<Arc<str>>,
209211
}
210212

211213
impl Hash for SourceMap {
@@ -241,6 +243,7 @@ impl SourceMap {
241243
sources_content: sources_content.into(),
242244
names: names.into(),
243245
source_root: None,
246+
debug_id: None,
244247
}
245248
}
246249

@@ -321,6 +324,16 @@ impl SourceMap {
321324
pub fn set_source_root<T: Into<Arc<str>>>(&mut self, source_root: Option<T>) {
322325
self.source_root = source_root.map(Into::into);
323326
}
327+
328+
/// Set the debug_id field in [SourceMap].
329+
pub fn set_debug_id<T: Into<Arc<str>>>(&mut self, debug_id: Option<T>) {
330+
self.debug_id = debug_id.map(Into::into);
331+
}
332+
333+
/// Get the debug_id field in [SourceMap].
334+
pub fn get_debug_id(&self) -> Option<&str> {
335+
self.debug_id.as_deref()
336+
}
324337
}
325338

326339
#[derive(Debug, Default, Deserialize)]
@@ -333,6 +346,8 @@ struct RawSourceMap {
333346
pub sources_content: Option<Vec<Option<String>>>,
334347
pub names: Option<Vec<Option<String>>>,
335348
pub mappings: String,
349+
#[serde(rename = "debugId")]
350+
pub debug_id: Option<String>,
336351
}
337352

338353
impl RawSourceMap {
@@ -411,6 +426,7 @@ impl TryFrom<RawSourceMap> for SourceMap {
411426
.collect::<Vec<_>>()
412427
.into();
413428
let source_root = raw.source_root.map(Into::into);
429+
let debug_id = raw.debug_id.map(Into::into);
414430

415431
Ok(Self {
416432
version: 3,
@@ -420,6 +436,7 @@ impl TryFrom<RawSourceMap> for SourceMap {
420436
sources_content,
421437
names,
422438
source_root,
439+
debug_id,
423440
})
424441
}
425442
}

0 commit comments

Comments
 (0)