melange-re.github.io icon indicating copy to clipboard operation
melange-re.github.io copied to clipboard

(Example) Expose `routes` library in playground

Open jchavarri opened this issue 2 months ago • 1 comments

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 in node_modules for bundling
  • Add a Dune rule to generate the cmijs from the library so they can be compiled "live" in the playground. Add this cmijs.js file to both the playground-assets and the app.jsx entry point so they get loaded in the browser.

And a screen capture:

image

jchavarri avatar Apr 23 '24 13:04 jchavarri