js_of_ocaml icon indicating copy to clipboard operation
js_of_ocaml copied to clipboard

[BUG] js_of_ocaml error, cannot parse javascript file

Open Ngoguey42 opened this issue 6 years ago • 1 comments

Using js_of_ocaml 3.5.2, my dune builds are failing when I attempt to include this file: https://cdnjs.cloudflare.com/ajax/libs/tensorflow/1.5.2/tf.js .

I narrowed down the problem to this:

$ js_of_ocaml --runtime-only tf.js
js_of_ocaml: Error: cannot parse file "tf.js" (orig:"tf.js" from l:22, c:417638)

Ngoguey42 avatar Feb 29 '20 18:02 Ngoguey42

Our javascript parser doesn't understand the getter syntax in objects

{get prop() { ... } }
{get [expression]() { ... } }

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get

A workaround is to not pass that file to jsoo and bundle it later.

hhugo avatar Mar 18 '20 13:03 hhugo