Skip to content

Commit 7d0e3c5

Browse files
committed
Order source map fields following the spec
Binaryen tools (up to version 123) expect this order.
1 parent 0d8fda8 commit 7d0e3c5

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

compiler/lib/source_map.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,7 @@ module Standard = struct
477477
, match t.sourceroot with
478478
| None -> None
479479
| Some s -> Some (stringlit s) )
480-
; "names", Some (`List (List.map t.names ~f:(fun s -> stringlit s)))
481480
; "sources", Some (`List (List.map t.sources ~f:(fun s -> stringlit s)))
482-
; "mappings", Some (stringlit (Mappings.to_string t.mappings))
483481
; ( "sourcesContent"
484482
, match t.sources_content with
485483
| None -> None
@@ -489,6 +487,8 @@ module Standard = struct
489487
(List.map l ~f:(function
490488
| None -> `Null
491489
| Some x -> Source_content.to_json x))) )
490+
; "names", Some (`List (List.map t.names ~f:(fun s -> stringlit s)))
491+
; "mappings", Some (stringlit (Mappings.to_string t.mappings))
492492
; ( "ignoreList"
493493
, match t.ignore_list with
494494
| [] -> None

compiler/tests-jsoo/empty_sourcemap.t

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ Build object files and executable with --empty-sourcemap:
88

99
$ dune exec -- js_of_ocaml --sourcemap --empty-sourcemap a.cmo -o a.js
1010
$ cat a.map
11-
{"version":3,"file":"a.js","names":[],"sources":[],"mappings":"","sourcesContent":[]}
11+
{"version":3,"file":"a.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
1212
$ dune exec -- js_of_ocaml --sourcemap --empty-sourcemap b.cmo -o b.js
1313
$ cat b.map
14-
{"version":3,"file":"b.js","names":[],"sources":[],"mappings":"","sourcesContent":[]}
14+
{"version":3,"file":"b.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
1515
$ dune exec -- js_of_ocaml --sourcemap --empty-sourcemap test.bc -o test.js
1616
$ cat test.map
17-
{"version":3,"file":"test.js","names":[],"sources":[],"mappings":"","sourcesContent":[]}
17+
{"version":3,"file":"test.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
1818

1919
Build object files with sourcemap and link with --empty-sourcemap:
2020

0 commit comments

Comments
 (0)