dune icon indicating copy to clipboard operation
dune copied to clipboard

melange: find out js artifact of a given ml source

Open jchavarri opened this issue 2 years ago • 3 comments

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.

jchavarri avatar Mar 31 '23 07:03 jchavarri

What about promoting all js?

Alizter avatar Mar 31 '23 13:03 Alizter

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 js files are not co-located with sources using promotion either. If you have a lib in foo/bar and a melange emit stanza in baz with target output, the js files for the library will be in baz/output/foo/bar. Still quite far from the sources. @anmonteiro had some attempts to remove target in 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

jchavarri avatar Mar 31 '23 16:03 jchavarri

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.

anmonteiro avatar Feb 16 '24 06:02 anmonteiro