These are chat archives for opal/opal

19th
Apr 2018
JPGDavis
@JPGDavis
Apr 19 2018 14:50

Hi all, I'm just trying to get the opal-parser example from the https://github.com/opal/opal page up and running but I'm falling at the first hurdle. I've got the example html copied in a local html file and I'm running it, only to get the following error in the chrome log: Uncaught TypeError: (cref || _Object).$const_missing is not a function .

I've tried with and without any extensions running... any ideas? I'm guess I'm missing something obvious.

eiko
@eiko
Apr 19 2018 15:13
@JPGDavis i tested the html in a local file as well and got the same error. i'm troubleshooting right now; will let you know if i find anything!
JPGDavis
@JPGDavis
Apr 19 2018 15:15
Thanks @eiko! I've tried in a few browsers now (Edge, etc) and I get the same. Thanks for confirmation.
JPGDavis
@JPGDavis
Apr 19 2018 15:21
JsFiddle shows the same error in the console https://jsfiddle.net/4xvc4jxd/4/
JPGDavis
@JPGDavis
Apr 19 2018 16:08
Oh! That one works fine! Strange that I couldn't get the versions from the example (at http://cdn.opalrb.com/opal/current/) to function. What was up?
eiko
@eiko
Apr 19 2018 16:13
i made that one by compiling Opal locally. the version i compiled defines the entire Opal library as JS and automatically loads it. the remote one defines the entire Opal library but doesn't load it
i have no idea why the remote one has this distinction. i'm looking through the Opal source code now
JPGDavis
@JPGDavis
Apr 19 2018 16:15
Thanks @eiko , thats enough for me to continue with my project for tonight anyhow. I really appreciate the help.
eiko
@eiko
Apr 19 2018 16:16
no problem! i love Opal, but it was a bumpy road for me to get started as well. i'm happy to smooth that road out for anyone else if i can ^-^
JPGDavis
@JPGDavis
Apr 19 2018 16:17
Hah, I was trying all kinds of things for a good hour or so. Thought I'd made a silly mistake somewhere. You've really helped me out :)
eiko
@eiko
Apr 19 2018 18:19

@JPGDavis in case you (or anyone else) are interested: the bug was introduced with the switch from Opal::Sprockets to Opal::Builder

opal/opal@05ef585

Opal::Sprockets had a special hard-coded line that automatically loaded a library if its name was "opal"

https://github.com/opal/opal-sprockets/blob/1fb7ec0752887c66bd04958f3c427649d37e6e13/lib/opal/sprockets/processor.rb#L43

but Opal::Builder doesn't have this hard-coded, so Opal is no longer loaded by default. i'll put in a pull request to fix it, but in the mean time, you can still use the CDN if you load Opal immediately after adding it:

<script src="http://cdn.opalrb.com/opal/current/opal.js"></script>
<script type="text/javascript">Opal.load('opal')</script>
JPGDavis
@JPGDavis
Apr 19 2018 22:20
Interesting stuff, nicely found.