et4te
et4te

Reputation: 233

How does one use dune to create a js_of_ocaml library?

I'm wondering what a dune file looks like for a library (rather than an executable) which compiles to js_of_ocaml and why is it recommended to use an executable instead?

Upvotes: 2

Views: 524

Answers (1)

Drup
Drup

Reputation: 3739

You don't need to do anything particular for libraries to make them compatible with js_of_ocaml: js_of_ocaml works on the final executable bytecode, regardless of the libraries.

That being said, if you want to use js-specific things, js_of_ocaml is also an ocaml library that you can just depends on and which will contain bindings to various javascript functions.

(library
  (name my_library)
  (public_name my_library)
  (libraries (js_of_ocaml))
)

For building js files, you should use the executable stanza (as per the dune docs).

Upvotes: 1

Related Questions