These are chat archives for opal/opal

14th
Jul 2016
Biarity
@Biarity
Jul 14 2016 02:59
Hi, I just found out about Opal & I love Ruby. One thing though, is it being maintained & considered production-ready? I have an existing JS app (MERN stack) & plan on converting it into Opal/Reactrb. I know this is a broad question, & I would appreaciate any opinions on the matter!
meh.
@meh
Jul 14 2016 03:06
Qudware, it's maintained, and people use it in production
hayley
@hayley
Jul 14 2016 03:08

@Qudware I'm just some random, but I'd say it's production ready. I've been following Opal's development since 2014 or so and I'd definitely say it's in active development. I have a few projects that have been using it for awhile (none open source unfortunately), and it's definitely made JS more pleasant to work with.

And if you're specifically interested in reactrb, there's an active gitter chat here for that too.

Jamie Gaskins
@jgaskins
Jul 14 2016 04:31
@Qudware One of my Clearwater apps has been in production since last year, around 3k LOC and monitors the status of food deliveries in real time across 55 markets all over the country. It'll be fine for whatever ya need. ;-)
Mitch VanDuyn
@catmando
Jul 14 2016 19:19
trying to get opal working with middleman does anybody know any tricks (@hayley, @fkchang) ?
@Qudware - We are using it all fairly large app (about 18K sloc of opal code I think) its in beta test. It uses opal + reactrb. Opal is very stable, and I can remember only finding one very obscure bug in the last couple of years.
hayley
@hayley
Jul 14 2016 19:32

@catmando what version of middleman? Where are you getting stuck? If you're using v3, it's stuck at Opal 0.7.X I believe, due to sprockets compatibility. I actually have a v3 project where I set up something external so that I could use a modern version of opal, but I was never quite thrilled with it.

And I'll post some example projects in a bit.

Mitch VanDuyn
@catmando
Jul 14 2016 19:33
i;m trying to use latest and greatest (v4) I found your blog post, but as you said that's v3...
hayley
@hayley
Jul 14 2016 19:35
@catmando yeah, I actually feel bad that that ranks since it's years old at this point. Time for an update...
here's a couple of sample projects: https://github.com/opal/opal.github.io/tree/source (make sure you're on the source branch) and https://github.com/fkchang/opal-playground - both are v4. And I'll see if I can put together quick instructions in the next 15 minutes or so (and write a more current blog post at some point too)
hayley
@hayley
Jul 14 2016 19:49

Here's half the instructions for now:
sprockets is no longer a default part of the middleman install, add this to your Gemfile:

gem 'middleman-sprockets', '4.0.0'

You will also need to then make the following changes to your config.rb:

activate :sprockets

after_configuration do
  Opal.paths.each do |p|
    sprockets.append_path p
  end
end

set :js_dir, 'app' # for instance if your ruby code is in <project>/source/app

The huge thing I haven't figured out is source maps support. Anyone here know how to add opal source maps support to middleman?

Mitch VanDuyn
@catmando
Jul 14 2016 20:07
hmmm... I also had to do this in the top level js file Opal.load('test') (assuming I have a single ruby file called test)
hayley
@hayley
Jul 14 2016 20:11

yeah, sorry, the actual JS stuff was the other half of the instructions I didn't include.

But yeah, as I understand it, as of 0.8 and greater, opal code does not auto-execute just because it got pulled in with sprockets (meaning you'd see its source in your compiled js file, but it wouldn't be running).

This does give you the flexibility of not having to worry about what order sprockets pulls your files in, but then (if you're using a .js file as an entry point), you'll need to do Opal.load('FILENAME') to make sure it executes.

Mitch VanDuyn
@catmando
Jul 14 2016 20:22
yeah - great... with your old blog post, etc, I have it all working pretty nice...
Mitch VanDuyn
@catmando
Jul 14 2016 20:58
My plan is to have a separate ruby directory so you will have
source
├── images
│   └── middleman-logo.svg
├── index.html.erb
├── javascripts
│   ├── all.js
│   └── some_js_code.js
├── layouts
│   └── layout.erb
├── ruby
│   ├── application.rb
│   ├── components
│   │   └── clock.rb
│   └── ruby.rb
└── stylesheets
    ├── _normalize.scss
    └── site.css.scss
BUT... that said I just discovered middleman-react, so I am off the play with that before going farther...
hayley
@hayley
Jul 14 2016 21:06

yeah, I have something similar with my v3 project. I have an opal directory with its own Gemfile and then a Rakefile that will build what's in the opal directory. Then I have a Procfile in the main middleman directory that runs middleman at the same time as the Rake rebuilder.

What I want to do though is experiment with getting webpack going both for JS dependencies and building opal files, especially given that the middleman devs seem so intent on divorcing the project from sprockets and using the external pipeline instead (external pipeline is v4 only though).

Forrest Chang
@fkchang
Jul 14 2016 22:08
@Qudware we have a public facing app in production and several internal facing apps.