These are chat archives for opal/opal

4th
Oct 2016
Jamie Gaskins
@jgaskins
Oct 04 2016 03:53
Anyone used Opal on Hanami? Trying to see what it's like getting Clearwater up and running on it but Hanami's asset compiler seems to ignore require statements, which makes me think it's not using Sprockets.
Elia Schito
@elia
Oct 04 2016 05:47
@jgaskins the doc says it's using Tilt https://github.com/hanami/assets/blob/master/README.md
Jamie Gaskins
@jgaskins
Oct 04 2016 16:07
@elia Yeah, I didn't know if Tilt can leverage Sprockets at all or if it just runs the one file through the compiler.
Elia Schito
@elia
Oct 04 2016 16:08
@jgaskins sprockets used to be based on tilt, but has diverged since v3
Jamie Gaskins
@jgaskins
Oct 04 2016 16:08
Oooooh, I see.
Elia Schito
@elia
Oct 04 2016 16:09
we have a basic support for vanilla tilt, but with the extraction of opal-sprockets on master I think it's worth introducing opal-tilt
which btw I think it's used by Roda too
Jamie Gaskins
@jgaskins
Oct 04 2016 16:10
Good idea. I spent a few hours on trying to get an Opal puts "hello world" app working on Hanami and couldn't get it to include any dependencies.
@elia Yeah, Roda's assets plugin's lack of dependency-loading support was the reason I wrote Roda::OpalAssets. It works fine on Roda because is has almost no indirection, but I couldn't do the same with Hanami.
@jgaskins not sure how you pass an option, but passing build: true should make it work
too bad I didn't had the time to look into Roda::OpalAssets, but let me know if you need anything
Jamie Gaskins
@jgaskins
Oct 04 2016 16:14
It'll work, but it also takes 1-2 seconds to compile every time because it doesn't reuse unchanged assets. :-) Or at least, it didn't last I checked. I used Sprockets because it's faster after the first page load.
@elia It's just a Rack app with a Sprockets layer that injects itself into Roda's router.
I'll give that build: true a shot and see how it works. Something working is better than nothing working. :-)
Elia Schito
@elia
Oct 04 2016 16:18
👍🏼 yes the vanilla builder has no cache support, sprockets is definitely more production-ready
Jamie Gaskins
@jgaskins
Oct 04 2016 16:29
I remember at one point being able to reuse the same Opal::Builder instance and it would go faster, but at some point I think that stopped being effective. I figured there might be internal reasons for that so I just started using Sprockets.
Oh wait, that may have been after 0.8 when Opal stopped concatenating files to get source maps working again.
Elia Schito
@elia
Oct 04 2016 16:45
This message was deleted
yes, btw I was doing some more experiments with concatenated sourcemaps last night, hopefully I'll find a decent way to test that and fix it
Elia Schito
@elia
Oct 04 2016 16:50
@jgaskins & /@all I was also tinkering with a super simple opal rack server https://gist.github.com/elia/4582426a573a0e5448c9dd7ab4deb310 but I'm a bit undecided about making it part of the opal gem or keeping it available just for the test suite – I'd love some feedback about it being useful to anybody
(on master Opal::Server is now Opal::Sprockets::Server and part of the opal-sprockets gem)
usage example:
run Opal::SimpleServer.new { |s|
  # the name of the ruby file to load. To use more files they must be required from here (see app)
  s.main = 'application'
  # the directory where the code is (add to opal load path )
  s.append_path 'app'
  # need to set the index explicitly for opal server to pick it up
  s.index_path = 'index.html.erb'
}
Jamie Gaskins
@jgaskins
Oct 04 2016 16:58
@elia Looks like that will accept all paths at the index?
If so, all the :+1:
Elia Schito
@elia
Oct 04 2016 16:59
yes, it's intended, to allow for SPA
Jamie Gaskins
@jgaskins
Oct 04 2016 17:00
Doing client-side routing was fine on Opal::Server until I had to refresh the page. :-) This is a welcome change.
Elia Schito
@elia
Oct 04 2016 17:00
beware it has no assets cache or anything it's the simplest thing you can have, but worked fine for me with example apps
Forrest Chang
@fkchang
Oct 04 2016 18:02
hmm, I'm wondering if a good place to talk about opal is at Ruby Kaigi. I'd submit a proposal, but I'm not in a position to travel to Japan any time soon (too many kids and dad duties to go 1/2 way across the world and strand my wife)
Guillaume Grossetie
@Mogztter
Oct 04 2016 19:35
Hello, I think we found an issue in Opal with bytesize method on String: https://github.com/asciidoctor/asciidoctor.js/pull/236#issuecomment-251305196
I'm not sure yet this is a bug in Opal, so I didn't want to create an issue :)
And do someone know why "UTF-16LE" is the default encoding ?
meh.
@meh
Oct 04 2016 19:38
Mogztter, JavaScript strings are UTF-16LE
they're not UTF-8
the problem is probably because of that, any dealing with encoding and/or binary is always bogus in JS
Guillaume Grossetie
@Mogztter
Oct 04 2016 19:41
Ok that explains the UTF-16LE
meh.
@meh
Oct 04 2016 19:41
Mogztter, I'm responding on the issue
Guillaume Grossetie
@Mogztter
Oct 04 2016 19:42
I saw, thanks ;)
but why bytesize method does not found bytes in a UTF-16 String ?
meh.
@meh
Oct 04 2016 19:44
Mogztter, yeah I'm checking that out
Guillaume Grossetie
@Mogztter
Oct 04 2016 19:44
Ok
meh.
@meh
Oct 04 2016 19:52
Mogztter, fixed on master
Guillaume Grossetie
@Mogztter
Oct 04 2016 19:59
too strong!
Thanks again @meh
meh.
@meh
Oct 04 2016 19:59
np
you still have to force the encoding if the string is ascii
but keep in mind if the string is not ascii, then bytesize might fuck up
Guillaume Grossetie
@Mogztter
Oct 04 2016 20:05
Ok I will see with Dan if the string is ascii or not
Forrest Chang
@fkchang
Oct 04 2016 20:41
@meh is very strong. I have not invoked that strength in a long while. I'm overdue