I'm trying to export a standalone library in JavaScript thanks to js_of_ocaml
.
To build the JavaScript file, I used this command:
js_of_ocaml --wrap-with-fun=stringextCma --pretty --no-cmis \
-I ~/.opam/learn-ocaml/lib/stringext \
~/.opam/learn-ocaml/lib/stringext/stringext.cma \
-o stringext.cma.js
I linked the script in an index.html file. However, when I try to use the function stringextCma(window)
to import it in the Firefox or Chromium console, it displays the following error:
TypeError: runtime is undefined
I don't find a way to correct it. Does someone else have this error and find a way to fix this ?
Edit
What I'm trying to achieve is almost the same as this issue. I try to follow the same steps, including wrapping the javascript code into a function.
I want to compile some opam libraries in JavaScript and load them into the learn-ocaml toplevel as javascript files (precompile). The problem is, when I load the script, I can't load it into the toplevel because I have different errors. First, I can't use the #load_js directive because the load_script function is unknown and when I try to import the library (here stringext), I have the runtime problem....
I don't know if this is clearer...