These are chat archives for opal/opal

17th
Feb 2018
Mitch VanDuyn
@catmando
Feb 17 2018 01:57
Does anybody understand why opal-jquery is required in the gem spec for opal-rails, but never seems to make it on the client? I'm sort of confused.
It seems like if you depend on opal-rails, then you also depend on opal-jquery
why?
or what am I missing?
Jamie Gaskins
@jgaskins
Feb 17 2018 07:22
@catmando if i had to guess, probably a relic from when jquery-rails was a dependency of Rails.
Elia Schito
@elia
Feb 17 2018 09:15
@catmando @jgaskins I think that’s the reason, back then the only viable “ujs” was the jquery one
Mitch VanDuyn
@catmando
Feb 17 2018 13:57
@elia @jgaskins yeah understand that BUT according to @janbiederman jquery is not actually "required" on the client side. So it seems like opal-jquery is not actually used, but yet things are still depending on it? Could that be the case? Or is @janbiedermann and myself missing something? I guess we could do a fork of opal-rails, remove the dependency and see what happens...
Elia Schito
@elia
Feb 17 2018 17:23
@catmando if you did rails new --javascript=opal it was automatically put in the application.js, it's probably not necessary since rail 5, If you want to send a PR that's be great, I'm ok with removing it from the gemspec
Mitch VanDuyn
@catmando
Feb 17 2018 17:26
@elia first I apologize if I am confusing things... this is second hand info via @janbiedermann and I may not fully understand. But can I confirm that as of now, there is no need for opal-rails to depend on any kind of jquery? If so yes, then definitely sounds like a quick PR to remove the dependency, and I will try it out. But if I have got it wrong, then I won't waste anybodies time :-) (any more time anyway)
and that if opal-rails currently does depend on jquery, its only a historical artifact that we can remove... if so I will test asap.
Elia Schito
@elia
Feb 17 2018 19:03
@catmando it’s a little more nuanced than that, up until rails 4 (more or less) it was required in order to work out of the box because jquery ujs was the only ujs available. We still support Rails 4 but I’m open to removing it possibly issuing a warning or some advice with proper instructions.
Mitch VanDuyn
@catmando
Feb 17 2018 19:04
nope that makes sense now
Elia Schito
@elia
Feb 17 2018 19:05
I’m also interested in knowing about the original issue you’re facing, if you can expand on that …
Mitch VanDuyn
@catmando
Feb 17 2018 19:05
@elia - not a big issue just confusion in documentation.
1) we depend on opal-jquery I know that
2) but in documentation we are saying that you have to require it client side (in assets manifest in in hyperloop import statement)
Answer
if you are on rails 4 it will be required
if you are rails 5 it will not (unless you want to yourself)
jolly good
So I was just confused: Why not require it if you need it, and if you don't need it why depend on it.
(I think :-) )
only other possibility would be to NOT depend on it, and make rails 4 folks add it to their Gemfile
Mitch VanDuyn
@catmando
Feb 17 2018 19:18
sorry not sure what that means? Does it mean that opal-jquery IS already required on the client if using opal-rails?
(I think I am just being really stupid here... sorry)
Jan Biedermann
@janbiedermann
Feb 17 2018 19:18
that means, opal-rails depends on oapl-jquery for sure
Mitch VanDuyn
@catmando
Feb 17 2018 19:18
we know that :-)
Jan Biedermann
@janbiedermann
Feb 17 2018 19:18
but if you want it on the client you need to require 'opal-ujs'
Mitch VanDuyn
@catmando
Feb 17 2018 19:19
so why do I need another require
Jan Biedermann
@janbiedermann
Feb 17 2018 19:19
in the app/assets/javacrypts/application.rb
Elia Schito
@elia
Feb 17 2018 19:20
yeah, requires it on the front end whenever opal_ujs is required, which happens automatically if you use rails new -jopal, but the -j option has been removed IIRC in rails 5
if you add opal-rails to an existing app you have to deal with your application.js (or .js.rb) by yourself of course, but then you probably want opal-jquery when you depend on jquery (which of course was the default for rails)
all of this is predicated on the idea of making it work out of the box with no additional hassle