ocsigen / js_of_ocaml

Compiler from OCaml to Javascript.
http://ocsigen.org/js_of_ocaml/
Other
943 stars 185 forks source link

[FEATURE REQUEST] More customization (or documentation) of `--source-map`. #1613

Open JasonGross opened 2 months ago

JasonGross commented 2 months ago

Is your feature request related to a problem? Please describe.

In the build system for my project, I generate a couple different versions of the .byte files, and then pick one and install it, renaming it in the process. When this happens, it seems like the .map files refer to the wrong files (and locations).

Describe the solution you'd like

I'd like the documentation to specify the constraints on correct use of --source-map, and, ideally, for the generated files to either be relocatable and renamable, or for js_of_ocaml to take options that tell --source-map how files will be relocated and renamed.

Questions that are not made clear in the documentation:

Describe alternatives you've considered

hhugo commented 2 months ago

does the .byte file have to have the same stem that the .js file will eventually have for --source-map to work correctly?

You can control the name of the generated file with -o FILE. When using source-map, the source-map filename is derived from the generated filename. For example, js_of_ocaml main.byte --source-map -o jsfile.js will generate a js file jsfile.js referencing a source-map file jsfile.map.

do I have to call js_of_ocaml on a .byte file whose directory relative to the cwd is the same as what it will be on the website I'm building, for --source-map to work? (it seems that it bakes in relative paths...)

By default, jsoo embed sources inside the sourcemap file to ease its usage. If you don't embed the sources, Don't you have the sources embeded ?