These are chat archives for opal/opal

12th
Aug 2015
Elia Schito
@elia
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
@RickCarlino
Aug 12 2015 02:11
So does Opal keep a binding object?
Elia Schito
@elia
Aug 12 2015 07:34
@RickCarlino no
Mitch VanDuyn
@catmando
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
@elia
Aug 12 2015 10:41
@catmando Try with Opal.require('application') where application is the name of your main file
Mitch VanDuyn
@catmando
Aug 12 2015 11:10
I tried with load and that helps. What is the difference?
Elia Schito
@elia
Aug 12 2015 11:11
same diff that require and load have in MRI
require will do it just once
Mitch VanDuyn
@catmando
Aug 12 2015 11:13
Gotcha
Elia Schito
@elia
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
@catmando
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?
//<![CDATA[
      if (typeof(Opal) !== 'undefined') {
        Opal.mark_as_loaded("opal");
Opal.mark_as_loaded("corelib/runtime.self");
Opal.mark_as_loaded("jquery.self");
Opal.mark_as_loaded("jquery_ujs.self");
Opal.mark_as_loaded("rspec/matchers/built_in/have");
Opal.mark_as_loaded("diff/lcs");
Opal.mark_as_loaded("diff/lcs/hunk");
Opal.mark_as_loaded("fileutils");
Opal.mark_as_loaded("test/unit/assertions");
Opal.mark_as_loaded("coderay");
Opal.mark_as_loaded("optparse");
Opal.mark_as_loaded("shellwords");
Opal.mark_as_loaded("socket");
Opal.mark_as_loaded("uri");
Opal.mark_as_loaded("drb/drb");
        Opal.load("application");
      }

//]]>
Or do i need to worry about it?
Elia Schito
@elia
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
@jaredcwhite
Aug 12 2015 17:00
George Plymale II
@ylluminarious
Aug 12 2015 17:03
:clap:
Mitch VanDuyn
@catmando
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
@elia
Aug 12 2015 17:47
@catmando 👍🏼
Rick Carlino
@RickCarlino
Aug 12 2015 19:04
@jaredcwhite :clap: Awesome!