|
2 | 2 |
|
3 | 3 | == Use the right compiler flags
|
4 | 4 | === OCaml flags
|
5 |
| -Make sure to use "-g" flags when compiling and linking ocaml bytecode. |
| 5 | +Make sure to use {{{-g}}} flags when compiling and linking ocaml bytecode. |
6 | 6 | Js_of_ocaml will attempt to preserve variable names.
|
7 | 7 |
|
8 | 8 | === Js_of_ocaml flags
|
9 |
| - * [--pretty] - format the generated JavaScript in a readable way and try to keep OCaml variable names. |
10 |
| - * [--no-inline] - prevent function inlining. |
11 |
| - * [--debug-info] - annotate the JavaScript file with locations from the OCaml sources. |
12 |
| - * [--source-map] - enable source-map support |
| 9 | + * {{{--pretty}}} - format the generated JavaScript in a readable way and try to keep OCaml variable names. |
| 10 | + * {{{--no-inline}}} - prevent function inlining. |
| 11 | + * {{{--debug-info}}} - annotate the JavaScript file with locations from the OCaml sources. |
| 12 | + * {{{--source-map}}} - enable source-map support |
13 | 13 |
|
14 | 14 | == JavaScript stacktrace
|
15 |
| -Js_of_ocaml can attach a JavaScript [Error] that embed the current |
16 |
| -stacktrace to an OCaml exception. The [Error] can be attached with |
| 15 | +Js_of_ocaml can attach a JavaScript {{{Error}}} that embed the current |
| 16 | +stacktrace to an OCaml exception. The {{{Error}}} can be attached with |
17 | 17 | {{{Js.Js_error.attach_js_backtrace}}} and extracted using
|
18 | 18 | {{{Js.Js_error.of_exn}}}. Un-handled OCaml exception will throw any
|
19 |
| -JavaScript [Error] attached to them, allowing the JS engine to display |
| 19 | +JavaScript {{{Error}}} attached to them, allowing the JS engine to display |
20 | 20 | the stacktrace nicely.
|
21 | 21 |
|
22 |
| -Js_of_ocaml will attach an [Error] automatically when raising an OCaml |
| 22 | +Js_of_ocaml will attach an {{{Error}}} automatically when raising an OCaml |
23 | 23 | exception (with {{{raise}}}, not with {{{raise_notrace}}}) if
|
24 | 24 | {{{Printexc.backtrace_status() = true}}} and either the environment
|
25 |
| -variable [OCAMLRUNPARAM] is set with [b=1] or the program was compiled |
26 |
| -with [--enable with-js-error]. |
| 25 | +variable {{{OCAMLRUNPARAM}}} is set with {{{b=1}}} or the program was compiled |
| 26 | +with {{{--enable with-js-error}}}. |
27 | 27 |
|
28 |
| -Note that creating JavaScript [Error]s is costly and can degrade performance a lot. |
| 28 | +Note that creating JavaScript {{{Error}}}s is costly and can degrade performance a lot. |
29 | 29 | This is the reason why such feature is not enabled by default.
|
30 | 30 |
|
31 | 31 | == Breakpoint
|
|
0 commit comments