Skip to content

Commit

Permalink
Fix source maps (#1356)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrus- authored Aug 10, 2024
2 parents 0d8ffbd + 0f3d80d commit f1274b6
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 39 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ helper functions for printing and serializing this data. For a type named `t`, t
for a type named something else like `q`, it will be `show_q`.

#### Source Maps
`js_of_ocaml` does support source maps and has some other flags that might be useful. If you experiment with those and get them to work, please update this README with some notes.
Source maps for `js_of_ocaml` should be configured when making locally with the dev profile (`make`). This is configured using the env stanzas present in the `dune` files for each top-level directory.

Since source maps are generated browser developer tools should show reason code in the debugger and source tree. Stack traces should also include reason line numbers.

#### Debug Mode
If Hazel is hanging on load or when you perform certain actions, you can load into Debug Mode by appending `#debug` to the URL and reloading. From there, you have some buttons that will change settings or reset local storage. Refresh without the `#debug` flag and hopefully you can resolve the situation from there.
Expand Down
18 changes: 8 additions & 10 deletions src/haz3lcore/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
(library
(name haz3lcore)
(libraries util sexplib unionFind uuidm virtual_dom yojson core)
(js_of_ocaml
(flags
(:include js-of-ocaml-flags-%{profile})))
(js_of_ocaml)
(preprocess
(pps
ppx_yojson_conv
Expand All @@ -14,10 +12,10 @@
ppx_sexp_conv
ppx_deriving.show)))

(rule
(write-file
js-of-ocaml-flags-dev
"(:standard --debuginfo --noinline --dynlink --linkall --sourcemap)"))

(rule
(write-file js-of-ocaml-flags-release "(:standard)"))
(env
(dev
(js_of_ocaml
(flags :standard --debuginfo --noinline --dynlink --linkall --sourcemap)))
(release
(js_of_ocaml
(flags :standard))))
8 changes: 8 additions & 0 deletions src/haz3lschool/dune
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@
(libraries ppx_yojson_conv.expander haz3lcore haz3lschool)
(preprocess
(pps ppx_yojson_conv ppx_let ppx_sexp_conv ppx_deriving.show)))

(env
(dev
(js_of_ocaml
(flags :standard --debuginfo --noinline --dynlink --linkall --sourcemap)))
(release
(js_of_ocaml
(flags :standard))))
21 changes: 3 additions & 18 deletions src/haz3lweb/dune
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
haz3lschool
pretty
omd)
(js_of_ocaml
(flags
(:include js-of-ocaml-flags-%{profile})))
(js_of_ocaml)
(preprocess
(pps
ppx_yojson_conv
Expand Down Expand Up @@ -48,9 +46,7 @@
haz3lschool
pretty
omd)
(js_of_ocaml
(flags
(:include js-of-ocaml-flags-%{profile})))
(js_of_ocaml)
(preprocess
(pps
js_of_ocaml-ppx
Expand All @@ -64,9 +60,6 @@
(modules Main)
(libraries ppx_yojson_conv.expander haz3lweb)
(modes js)
(js_of_ocaml
(flags
(:include js-of-ocaml-flags-%{profile})))
(preprocess
(pps
ppx_yojson_conv
Expand All @@ -86,15 +79,7 @@
(env
(dev
(js_of_ocaml
(flags (:standard))))
(flags :standard --debuginfo --noinline --dynlink --linkall --sourcemap)))
(release
(js_of_ocaml
(flags (:standard)))))

(rule
(write-file
js-of-ocaml-flags-dev
"(:standard --debuginfo --noinline --dynlink --linkall --sourcemap)"))

(rule
(write-file js-of-ocaml-flags-release "(:standard)"))
8 changes: 8 additions & 0 deletions src/pretty/dune
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@
(libraries util sexplib)
(preprocess
(pps ppx_let ppx_sexp_conv)))

(env
(dev
(js_of_ocaml
(flags :standard --debuginfo --noinline --dynlink --linkall --sourcemap)))
(release
(js_of_ocaml
(flags :standard))))
18 changes: 8 additions & 10 deletions src/util/dune
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
(library
(name util)
(libraries re base ptmap incr_dom virtual_dom yojson)
(js_of_ocaml
(flags
(:include js-of-ocaml-flags-%{profile})))
(js_of_ocaml)
(preprocess
(pps
ppx_yojson_conv
Expand All @@ -12,10 +10,10 @@
ppx_sexp_conv
ppx_deriving.show)))

(rule
(write-file
js-of-ocaml-flags-dev
"(:standard --debuginfo --noinline --dynlink --linkall --sourcemap)"))

(rule
(write-file js-of-ocaml-flags-release "(:standard)"))
(env
(dev
(js_of_ocaml
(flags :standard --debuginfo --noinline --dynlink --linkall --sourcemap)))
(release
(js_of_ocaml
(flags :standard))))

0 comments on commit f1274b6

Please sign in to comment.