melange-re.github.io
melange-re.github.io copied to clipboard
(Example) Expose `routes` library in playground
This is just a small example based on a Twitter convo with @ManasJayanth about exposing "regular" OCaml libraries in the playground.
The changes required are the following:
- The libraries added need to be compatible with Melange. See the related PR in routes repo: https://github.com/anuragsoni/routes/pull/151
- Add the package to the doc site opam file
- Add the libraries to the playground
melange.emit
stanza. This makes sure that the generated JS files will be available innode_modules
for bundling - Add a Dune rule to generate the
cmijs
from the library so they can be compiled "live" in the playground. Add thiscmijs.js
file to both theplayground-assets
and theapp.jsx
entry point so they get loaded in the browser.
And a screen capture: