dune
dune copied to clipboard
melange: find out js artifact of a given ml source
Dune and Melange default to placing .js artifacts in _build folder. In comparison, ReScript default behavior is to put .js artifacts next to the sources.
To help Melange users look at the resulting .js files, it would be nice to have the ability to "Inspect JavaScript output" from editors. To do so, Dune could look up all the melange.emit stanzas in the workspace and search for the given module emitted in them. Then editor tooling libraries could consume this functionality through rpc.
What about promoting all js?
That could work. I personally haven't tested promotion mode much (or at all 😅 ) with Melange. But even if I had, it has a couple of downsides:
- The
jsfiles are not co-located with sources using promotion either. If you have a lib infoo/barand a melange emit stanza inbazwith targetoutput, the js files for the library will be inbaz/output/foo/bar. Still quite far from the sources. @anmonteiro had some attempts to removetargetin https://github.com/ocaml/dune/pull/6541, but I'm not sure it's feasible in the short term. - Promotion is not the default mode in Dune, so I assume the majority of Melange users to have their projects configured in regular, "non-promoted" mode
This is a bit tricky because e.g. a library libA can be included in multiple melange.emits, so there will be several JS targets for it. If we were to implement this, we'd need to find all the targets where it appears and list them under the respective melange.emit stanzas that they belong to.