ocaml / dune

A composable build system for OCaml.
https://dune.build/
MIT License
1.56k stars 394 forks source link

Dune does not recognise separate source map files from js_of_ocaml #10673

Open katrinafyi opened 1 week ago

katrinafyi commented 1 week ago

Expected Behavior

Hello, I am compiling a module using jsoo using separate sourcemap files. After passing --sourcemap in both flags and link_flags, js_of_ocaml will emit both .bc.js and .bc.map file into the build folder.

We expect that Dune is aware of the .js and .map files, and we should be able to reference these in other rules. For example, this dune file should install both the compiled Javascript and its source map into the bin directory.

(executable
  (name builder)
  (modes js)
  (modules builder)

  (js_of_ocaml (flags --sourcemap :standard \ --source-map-inline)
               (link_flags --sourcemap :standard \ --source-map-inline)))

; static files for distribution
(install
 (files builder.bc.js builder.map.js)
 (section bin))

Actual Behavior

Dune does not recognise the .map file ("no rule found") and fails the build.

File "web/dune", line 28, characters 22-36:
28 |  (files builder.bc.js builder.bc.map index.html)
                           ^^^^^^^^^^^^^^
Error: No rule found for web/builder.bc.map

Reproduction

  1. Attempt a build with a dune file similar to the above. For convenience, I have created a minimal dune project here: jsoo_sourcemap_missing.tar.gz.
  2. Observe the error when running dune build.
  3. Note the source map is present in the build directory: ls _build/default/web/
  4. Observe a successful build when omitting the .map.js from the install clause of web/dune.

Specifications

rgrinberg commented 1 week ago

@hhugo what should we do?