js_of_ocaml icon indicating copy to clipboard operation
js_of_ocaml copied to clipboard

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

Open JasonGross opened this issue 1 year ago • 1 comments

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:

  • does the .byte file have to have the same stem that the .js file will eventually have for --source-map to work correctly?
  • 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...)

Describe alternatives you've considered

JasonGross avatar May 13 '24 04:05 JasonGross

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 ?

hhugo avatar May 13 '24 15:05 hhugo