@@ -173,14 +173,19 @@ let prefix_kind line =
173173 | true -> `Json_base64 (String. length sourceMappingURL_base64)
174174 | false -> `Url (String. length sourceMappingURL))
175175
176+ let rule_out_index_map = function
177+ | `Standard sm -> sm
178+ | `Index _ -> failwith " unexpected index map at this stage"
179+
176180let action ~resolve_sourcemap_url ~drop_source_map file line =
177181 match prefix_kind line, drop_source_map with
178182 | `Other , (true | false ) -> Keep
179183 | `Unit , (true | false ) -> Unit
180184 | `Build_info bi , _ -> Build_info bi
181185 | (`Json_base64 _ | `Url _ ), true -> Drop
182186 | `Json_base64 offset , false ->
183- Source_map (Source_map_io. of_string (Base64. decode_exn ~off: offset line))
187+ Source_map (
188+ rule_out_index_map (Source_map_io. of_string (Base64. decode_exn ~off: offset line)))
184189 | `Url _ , false when not resolve_sourcemap_url -> Drop
185190 | `Url offset , false ->
186191 let url = String. sub line ~pos: offset ~len: (String. length line - offset) in
@@ -189,7 +194,7 @@ let action ~resolve_sourcemap_url ~drop_source_map file line =
189194 let l = in_channel_length ic in
190195 let content = really_input_string ic l in
191196 close_in ic;
192- Source_map (Source_map_io. of_string content)
197+ Source_map (rule_out_index_map ( Source_map_io. of_string content) )
193198
194199module Units : sig
195200 val read : Line_reader .t -> Unit_info .t -> Unit_info .t
@@ -471,12 +476,12 @@ let link ~output ~linkall ~mklib ~toplevel ~files ~resolve_sourcemap_url ~source
471476 | _ -> false );
472477 { version = init_sm.version
473478 ; file = init_sm.file
474- ; Composite . sections =
479+ ; Index . sections =
475480 (let _, sections =
476481 List. fold_right
477482 sourcemaps_and_line_counts
478483 ~f: (fun (sm , generated_line_count ) (cur_ofs , sections ) ->
479- let offset = Composite . { gen_line = cur_ofs; gen_column = 0 } in
484+ let offset = Index . { gen_line = cur_ofs; gen_column = 0 } in
480485 cur_ofs + generated_line_count, (offset, `Map sm) :: sections)
481486 ~init: (0 , [] )
482487 in
@@ -493,11 +498,11 @@ let link ~output ~linkall ~mklib ~toplevel ~files ~resolve_sourcemap_url ~source
493498 in
494499 (match file with
495500 | None ->
496- let data = Source_map_io.Composite . to_string merged_sourcemap in
501+ let data = Source_map_io.Index . to_string merged_sourcemap in
497502 let s = sourceMappingURL_base64 ^ Base64. encode_exn data in
498503 Line_writer. write oc s |> ignore
499504 | Some file ->
500- Source_map_io.Composite . to_file merged_sourcemap file;
505+ Source_map_io.Index . to_file merged_sourcemap file;
501506 let s = sourceMappingURL ^ Filename. basename file in
502507 Line_writer. write oc s |> ignore);
503508 if times () then Format. eprintf " sourcemap: %a@." Timer. print t
0 commit comments