Skip to content

Commit 03ce7f5

Browse files
authored
Turbopack: charset=utf-8 in data-url source maps (#77112)
Previously, inline `sourceMappingURL` comments with `data:application/json;charset=utf-8;base64,....` were just ignored, only `data:application/json;base64,....` worked Is there an easy way to test this?
1 parent d89ebca commit 03ce7f5

File tree

1 file changed

+5
-1
lines changed
  • turbopack/crates/turbopack-ecmascript/src/references

1 file changed

+5
-1
lines changed

turbopack/crates/turbopack-ecmascript/src/references/mod.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,10 @@ pub(crate) async fn analyse_ecmascript_module_internal(
693693

694694
let mut source_map_from_comment = false;
695695
if let Some((_, path)) = paths_by_pos.into_iter().max_by_key(|&(pos, _)| pos) {
696+
lazy_static! {
697+
static ref JSON_DATA_URL_BASE64: Regex =
698+
Regex::new(r"^data:application\/json;(?:charset=utf-8;)?base64").unwrap();
699+
}
696700
let origin_path = origin.origin_path();
697701
if path.ends_with(".map") {
698702
let source_map_origin = origin_path.parent().join(path.into());
@@ -703,7 +707,7 @@ pub(crate) async fn analyse_ecmascript_module_internal(
703707
let source_map = reference.generate_source_map();
704708
analysis.set_source_map(source_map.to_resolved().await?);
705709
source_map_from_comment = true;
706-
} else if path.starts_with("data:application/json;base64,") {
710+
} else if JSON_DATA_URL_BASE64.is_match(path) {
707711
let source_map = maybe_decode_data_url(path.into());
708712
let source_map =
709713
resolve_source_map_sources(source_map.as_ref(), origin_path).await?;

0 commit comments

Comments
 (0)