ocamljs-of-ocaml

(js_of_ocaml) how to solve "Error: Unbound module Js"?


I want to re-compile a set of files to generate a .js file in my Mac. It used to work (long time ago), I don't know why it does not work anymore.

It returned:

$ make analyzejs
ocamlfind ocamlc -g unix.cma -package js_of_ocaml.ppx -I /Users/chengtie/lib -I hack -I functor -I params -I concrete -I pd -I ai -I domains -I frontend -I frontend/gen -I syntax -I lib -I main -I rules -I area -I values -I vars -I zones -I microsoft -I experiment -I expression -I abstract -I operator -I ev -I js -I /Users/chengtie/.opam/4.02.3/lib/xmlm -annot -c lib/array2_js.ml
File "lib/array2_js.ml", line 17, characters 50-54:
Error: Unbound module Js

my lib/array2_js.ml:

open Array2

module Array2_js:
  sig
    val of_js: (('a Js.js_array Js.t) Js.js_array Js.t) -> ('a -> string) ->
      string array array
    val of_js_shift :int -> int -> 'b ->
      (('a Js.js_array Js.t) Js.js_array Js.t) -> ('a -> 'b) -> 'b array array
    val of_js_f2_shift: int -> int -> 'b ->
      (('a Js.js_array Js.t) Js.js_array Js.t) ->
      (('a Js.js_array Js.t) Js.js_array Js.t) ->
      ('a -> 'a -> 'b) -> 'b array array
  end
=
struct
  (* {can better}: don't know why f:'a -> 'b is not permitted; *)
  let of_js (s: ('a Js.js_array Js.t) Js.js_array Js.t) (f: 'a -> string) :
    string array array =
    let s = Js.to_array s in
    let num_rows = Array.length s in
    let num_columns = Array.length (Js.to_array s.(0)) in
    (* pffo "num_rows_1: %d, num_columns_1: %d\n" num_rows num_columns; *)
    let t = Array2.make num_rows num_columns "" in
$ js_of_ocaml --version returned 3.5.2.

Could anyone help?


Solution

    1. open Js_of_ocaml at the top of array2_js.ml
    2. update the command line with -package js_of_ocaml-ppx (instead of -package js_of_ocaml.ppx