@@ -331,7 +331,10 @@ let json ?replace_mappings t =
331331 | Some s -> rewrite_path s) )
332332 ; " names" , `List (List. map t.names ~f: (fun s -> stringlit s))
333333 ; " sources" , `List (List. map t.sources ~f: (fun s -> stringlit (rewrite_path s)))
334- ; " mappings" , stringlit (Option. value ~default: (string_of_mapping t.mappings) replace_mappings)
334+ ; ( " mappings"
335+ , stringlit (match replace_mappings with
336+ | None -> string_of_mapping t.mappings
337+ | Some m -> m) )
335338 ; ( " sourcesContent"
336339 , `List
337340 (match t.sources_content with
@@ -409,10 +412,12 @@ let of_json ~parse_mappings (json : Yojson.Raw.t) =
409412 | None -> None
410413 | Some s -> Some (Source_content. of_stringlit s)))
411414 in
415+ let mappings_str = string " mappings" rest in
412416 let mappings =
413- match string " mappings" rest with
414- | None -> mapping_of_string " "
415- | Some s -> mapping_of_string s
417+ match parse_mappings, mappings_str with
418+ | false , _ -> mapping_of_string " "
419+ | true , None -> mapping_of_string " "
420+ | true , Some s -> mapping_of_string s
416421 in
417422 ( { version = int_of_float (float_of_string version)
418423 ; file
@@ -422,7 +427,7 @@ let of_json ~parse_mappings (json : Yojson.Raw.t) =
422427 ; sources
423428 ; mappings
424429 }
425- , if parse_mappings then None else Some mappings )
430+ , if parse_mappings then None else mappings_str )
426431 | _ -> invalid ()
427432
428433let of_string s = of_json ~parse_mappings: true (Yojson.Raw. from_string s) |> fst
0 commit comments