These are chat archives for opal/opal

Aug 2015
Elia Schito
Aug 12 2015 00:34
@catmando please do the PR, here's kinda late but I'll check stuff tomorrow
the conversation you re referring to I think is that about collapsing certain assets to a single file
to avoid the humongous number of script src tags in dev
Rick Carlino
Aug 12 2015 02:11
So does Opal keep a binding object?
Elia Schito
Aug 12 2015 07:34
@RickCarlino no
Mitch VanDuyn
Aug 12 2015 10:35

@elia @adambeynon @meh @vais I am seeing a change between 0.7 and 0.8 that I can't figure out:
I am using rails-react to prerender opal. To do this rails-react looks for a components.js file that should require all the components to be loaded into V8 for prerendering. So in 0.7 I simply required 'opal' plus any other gems that I was using as well as the actual components. All worked fine.

In 0.8 here is what I see (poking with the debugger and the rubyracer interface into the JS engine) :

Opal seems to have been loaded fine, but the rest of the requires are simply not there. Other normal JS code in the components.js file after the requires executes just fine.

I am wondering if the way loading and requires has changed somehow and I have to do something more to get all this required code to have been actually loaded into the Opal name space?

Thanks in advance.

Elia Schito
Aug 12 2015 10:41
@catmando Try with Opal.require('application') where application is the name of your main file
Mitch VanDuyn
Aug 12 2015 11:10
I tried with load and that helps. What is the difference?
Elia Schito
Aug 12 2015 11:11
same diff that require and load have in MRI
require will do it just once
Mitch VanDuyn
Aug 12 2015 11:13
Elia Schito
Aug 12 2015 11:13
that's the price for having requires behave like they do in MRI (sequence, if checks, etc)
and for having sourcemaps play nicely :)
Mitch VanDuyn
Aug 12 2015 12:05
@elia - thanks. I figured it was something like that looking at the following. My question is how does this get generated and how can I duplicate it when running in react-rails? Is there a method that will generate this block?
      if (typeof(Opal) !== 'undefined') {

Or do i need to worry about it?
Elia Schito
Aug 12 2015 12:18
@catmando Yeah, sure, sorry :)
The method is Opal::Processor.load_asset_code(sprockets_env, name)
the mark as loaded are for stubs and non-opal libraries which are marked as required before the main is required
so for example require 'jquery' inside of an opal file will result in a noop
Jared White
Aug 12 2015 17:00
George Plymale II
Aug 12 2015 17:03
Mitch VanDuyn
Aug 12 2015 17:32
@elia - thanks for the help... reactive_record and its friends upgraded to latest opal and all specs passing
@jaredcwhite NICE!
Elia Schito
Aug 12 2015 17:47
@catmando 👍🏼
Rick Carlino
Aug 12 2015 19:04
@jaredcwhite :clap: Awesome!