I’m looking for information about using Js_of_ocaml with Google’s Closure compiler and tools. I tried using the latter to compile some of the test code from Jsoo but it throws tons of “could not determine type of this expression” errors. I understand there are some restrictions on the code the Closure compiler can handle. Is it feasible with Jsoo?
I read rapidly through Understanding the Restrictions Imposed by the Closure Compiler | Google Developers and couldn’t find things that look problematic to me, but you shouldn’t take my word for it as I’m quite new to the kind of code that js_of_ocaml can output. Maybe @hhugo will know better.
Have you taken care to give Closure a standalone JS file (i.e. not the result of a partial compilation by js_of_ocaml)?
Nope. I’m pretty much flying blind. I know Clojurescript uses the Closure compiler to good effect; it evidently does some superbad optimizations so I thought I’d give it a try with jsoo. I’m the OBazl author; I’ve got jsoo building under bazel, and I can feed the output to the
js_binary rule of the rules_js ruleset, which automatically handles the node toolchain, so it can be run under Bazel (e.g.
bazel run compiler/tests-ocaml/lib-bigarray:bigarrays.exe.js). Thought I might see if I can get it working with rules_closure.
I’m have no experience at all with OBazl; I guess it would be needed to inspect the code at the locations of the errors to know more.
(Cite: I was an early contributor to the Clojurescript compiler, and had my hands in a lot of the code that emitted JS sources that had to conform to Closure’s constraints.)