Open jchavarri opened 1 year ago
An idea by @anmonteiro
we could expose a variable
%{melange:module_system}
The goal of this would be to have the library itself have the package.json as runtime_dep
but only for the case where there's es6
being emitted.
I'm not sure how actionable this is. We can't include a static package.json because the module system could be commonjs
.
I think the action item here is: document it and offer the dune rules in the website.
@jchavarri how do you feel about this one now that you have had some more production experience?
As we ended up with this convention of using as few melange emit stanzas as possible, I think it's not too bad to add the rules manually when needed. Maybe we can move the issue to melange-re.github.io repo to document it.
Rescript es6 version of stdlib included a
package.json
with"type": "module"
https://github.com/rescript-lang/rescript-compiler/blob/77b6a3bcd63989d2fb015c8a2543d87f3cb45007/lib/es6/package.json
This comes useful when running nodejs apps with es6 bundling, as otherwise one has to resort to workarounds like custom node loaders, using
mjs
extensions and such.There is a workaround using dune rules:
But it has to be defined for the 3 libraries exposed by Melange, and also replicated for every melange.emit stanza used.
I wonder if Melange could include
package.json
files similarly. The problem applies to any library really, so there might be some generic solution out there. Most probably it needs some coordination with Dune? 🤔cc @denis-ok