These are chat archives for opal/opal

11th
Mar 2016
Sean Scally
@scally
Mar 11 2016 00:13
Has anyone tried adding opal to an existing js app via requirejs/node? I see a lot of examples of adding it to rails/ruby apps, but nothing on how to add it when most of your tooling is grunt/nodejs/requirejs based
Elia Schito
@elia
Mar 11 2016 00:17
@scally I did some stuff with electron, the simplest way to get code compiled for node is to use the CLI
opal -ropal/platform -e 'puts "hi"' -c > code.js
requiring opal/platform detects the platform and sets up thins accordingly (IO output etc)
Sean Scally
@scally
Mar 11 2016 00:18
@elia thanks! to clarify, is the idea there to just shell out to opal from the js build pipeline and just compile up all .rb files?
Elia Schito
@elia
Mar 11 2016 00:20
I think it's the simplest way, but sky's the limit, opal can compile itself to js so you can wire up stuff to use that instead
Sean Scally
@scally
Mar 11 2016 00:21
Are there any examples out there similar to this approach? Thanks for your response
Elia Schito
@elia
Mar 11 2016 00:22
I did the opal package that I think it's still on npm, and available at github.com/opal/opal-node
but I think it uses old apis
it used to work with the node require system tho :)
also I think @Mogztter is trying to do something similar for asciidoc.js
Sean Scally
@scally
Mar 11 2016 00:23
Yeah, saw that one, I'll continue to try to get it to work. Right now I just added it to package.json and tried requiring up opal via requirejs, but haven't had luck with it yet, so felt maybe I was trying the wrong thing
Elia Schito
@elia
Mar 11 2016 00:24
I suggest to start over and compile a ruby file requiring opal-parser, and restart from there
the main issue I found was that nodejs preferred it's module style but opal taps inherently into global state (e.g. all classes are globals, as it happens in JS where String, Array etc are globals)
anyway opal -ropal-parser -e ' ' -c > opal-parser.js should give you all the tooling you need to compile ruby to js from node
Sean Scally
@scally
Mar 11 2016 00:28
I'll try that, thanks
Elia Schito
@elia
Mar 11 2016 00:29
after you require it from node you just: Opal.compile("puts 5");
Martin Becker
@Thermatix
Mar 11 2016 01:37
I'm sorry but, I think trying to run opal in node is hilarious, it's basicly inverting ruby on the back-end and javascript on the front-end. Nothing wrong with it just funny.
Sean Scally
@scally
Mar 11 2016 01:37
LOL, yeah, I can see that.
I'm just trying to see if this idea is even possible, I'd probably not recommend it as a great architectural approach
I much prefer the ruby build tooling
Martin Becker
@Thermatix
Mar 11 2016 10:24
I wasn't saying it was wrong, just pointing it out
ylluminate
@ylluminate
Mar 11 2016 19:04
congrats @ylluminarious, opal-phaser was just noted by Ruby Weekly: http://rubyweekly.com/issues/288
Ilya Bylich
@iliabylich
Mar 11 2016 19:05
:+1: Good job!
ylluminate
@ylluminate
Mar 11 2016 19:05
pretty awesome
George Plymale II
@ylluminarious
Mar 11 2016 19:06
@ylluminate just saw :D