Skip to content

Commit

Permalink
feat: Read debug IDs from debugId field (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
loewenheim authored Nov 6, 2024
1 parent d13cea7 commit 5596603
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Various fixes and improvements

- Debug IDs can be read from the "debugId" field in addition to "debug_id" (#97) by @loewenheim.

## 9.0.0

### Various fixes and improvements
Expand Down
2 changes: 1 addition & 1 deletion src/jsontypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub struct RawSourceMap {
pub x_metro_module_paths: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub x_facebook_sources: FacebookSources,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none", alias = "debugId")]
pub debug_id: Option<DebugId>,
}

Expand Down
15 changes: 15 additions & 0 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,21 @@ mod tests {
assert_eq!(new_sm.debug_id, Some(DebugId::default()));
}

#[test]
fn test_debugid_alias() {
let input: &[_] = br#"{
"version":3,
"sources":["coolstuff.js"],
"names":["x","alert"],
"mappings":"AAAA,GAAIA,GAAI,EACR,IAAIA,GAAK,EAAG,CACVC,MAAM",
"debugId":"00000000-0000-0000-0000-000000000000"
}"#;

let sm = SourceMap::from_slice(input).unwrap();

assert_eq!(sm.debug_id, Some(DebugId::default()));
}

#[test]
fn test_adjust_mappings_injection() {
// A test that `adjust_mappings` does what it's supposed to for debug id injection.
Expand Down

0 comments on commit 5596603

Please sign in to comment.