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 1 year 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

I fed this PR to ChatGPT and asked it to create instructions for new contributors. Does it look useful?

https://chat.openai.com/share/860d8e97-3055-458e-9c22-10f7b7c1b8e8

ManasJayanth avatar Apr 25 '24 08:04 ManasJayanth