@@ -331,7 +331,10 @@ let json ?replace_mappings t =
331
331
| Some s -> rewrite_path s) )
332
332
; " names" , `List (List. map t.names ~f: (fun s -> stringlit s))
333
333
; " 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) )
335
338
; ( " sourcesContent"
336
339
, `List
337
340
(match t.sources_content with
@@ -409,10 +412,12 @@ let of_json ~parse_mappings (json : Yojson.Raw.t) =
409
412
| None -> None
410
413
| Some s -> Some (Source_content. of_stringlit s)))
411
414
in
415
+ let mappings_str = string " mappings" rest in
412
416
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
416
421
in
417
422
( { version = int_of_float (float_of_string version)
418
423
; file
@@ -422,7 +427,7 @@ let of_json ~parse_mappings (json : Yojson.Raw.t) =
422
427
; sources
423
428
; mappings
424
429
}
425
- , if parse_mappings then None else Some mappings )
430
+ , if parse_mappings then None else mappings_str )
426
431
| _ -> invalid ()
427
432
428
433
let of_string s = of_json ~parse_mappings: true (Yojson.Raw. from_string s) |> fst
0 commit comments