These are chat archives for opal/opal

22nd
Mar 2016
Jamie Gaskins
@jgaskins
Mar 22 2016 12:34
@Thermatix There's a team in Sweden developing an OS X app on top of Electron and Clearwater (I don't know what yet, they've just opened a few issues on the Clearwater repo), so that's doable but AFAIK Electron doesn't have iOS support.
Elia Schito
@elia
Mar 22 2016 13:06
@jgaskins cool, congratz!
Martin Becker
@Thermatix
Mar 22 2016 13:56
I was thinking of using ionic
or cordova
specificly
Adam Jahn
@ajjahn
Mar 22 2016 14:47
@elia strange. I'll investigate rack and opal versions and let you know what I find.
Elia Schito
@elia
Mar 22 2016 14:50
@ajjahn here's the commit, opal/opal@ccef813 let me know if you find out something
Adam Jahn
@ajjahn
Mar 22 2016 16:15
@elia Ah yes. Indeed opal-rails forced an older opal version, and I failed to notice.
Elia Schito
@elia
Mar 22 2016 16:16
ugh
@ajjahn if you could fix it and send a PR (or point to an existing one that solves) that'd be awesome, I'm a bit behind on that side
Adam Jahn
@ajjahn
Mar 22 2016 16:36
@elia Sure.
Adam Jahn
@ajjahn
Mar 22 2016 16:47
@elia https://github.com/opal/opal-rails/commit/25397a72c85dba19807e4f4ea6ae12c8e07cdf4f#diff-befe212fa48f0eefd35d38431aeed885R25 allows Opal 0.9.x. Looks like a new version of opal-rails just needs to be released.
Elia Schito
@elia
Mar 22 2016 16:51
@ajjahn problem with that is that master is still W(IP)
but it bothers me a bit that the specs ain't passing
Forrest Chang
@fkchang
Mar 22 2016 16:59
@Thermatix I'm planning to use react.rb w/react-native for mobile apps at some point. @zetachang already did an attempt a while back, so it's definitely possible
@elia are you keeping opal-rails version numbers in lockstep w/opal versions, i.e. should a 0.9 opal compatible opal-rails be 0.9.x ?
Elia Schito
@elia
Mar 22 2016 17:01
happened kinda accidentally, at a point any release was bound to an opal release
but I'm not enforcing it
actually I started a bit of an overhaul lately but I still have to complete it
Forrest Chang
@fkchang
Mar 22 2016 17:02
@jgaskins nice... clearwater is taking over the world a bit at a time!
Elia Schito
@elia
Mar 22 2016 17:02
in which the support for opal-rspec was in a separate gem
thus allowing for opal-minitest-rails etc.
Forrest Chang
@fkchang
Mar 22 2016 19:03
@elia I think strict versions for clear compatibility is probably necessary, no?
Mitch VanDuyn
@catmando
Mar 22 2016 19:24
@fkchang - regarding webpack - would it make since to integrate this with the Gemfile... so you would have some syntax to specifiy things to load in the Gemfile?
Elia Schito
@elia
Mar 22 2016 19:50
@fkchang yeah, I was thinking about an additional Opal-rails release without the Opal version changing
George Plymale II
@ylluminarious
Mar 22 2016 20:08
@jaredcwhite nice job on the last opalist issue; there were some pretty interesting news items in there and i was surprised to see opal-phaser yet again XD (though we definitely appreciate the support).
nice job also @jgaskins for getting on the ruby rogues podcast
Jared White
@jaredcwhite
Mar 22 2016 21:03
@ylluminarious sure thing, thanks!
Forrest Chang
@fkchang
Mar 22 2016 21:04
@catmando I'm open to configuration and dependency resolving ideas. I'd love to had a gem you just include from the ruby backend side to add webpack (possibly a generator). I also want to get certain requirements into package.json so all the javascript things have the right version, and at somepoint, we'll probably need to version webpack versions as it changes over time.
Mitch VanDuyn
@catmando
Mar 22 2016 21:10
@fkchang - I am just too ignorant of webpack... I read since last week, but have not tried anything.
Do you think we must have both webpack and rails?
Or could you have rails, and then have webpack-bundler that reads the gemfile, and sees: webpack 'foo-bar' and does the equivilent webpack command to add foo-bar to the mix? Does that even make sense?
Brady Wied
@wied03
Mar 22 2016 21:25
@catmando @fkchang - I think if you bring in webpack, you're probably already half way into the NPM ecosystem. I've had discussions with fkchang about this before in this room. Without getting into which is better, I absolutely think webpack and sprockets are mutually exclusive when used for their intended purpose. Why connect the Gemfile into the mix there? I can think of 1 case to make such a linkage and that's due to the fact that most opal related libraries are distributed as GEMs. Given that's the case, I think if anything, the work would be to build a plugin for webpack such that it can find JS assets in GEMs (whether the be from rails-assets, opal related GEMs, etc.)
Elia Schito
@elia
Mar 22 2016 21:27
@wied03 a nice way to add that info would be to use the metadata field of the gemspec
Mitch VanDuyn
@catmando
Mar 22 2016 21:39
@wied03 - like I said I plead total ignorance... so if webpack and sprockets are mutually exclusive, then does it make sense to abandon sprockets in a rails app, and use webpack exclusively?
Brady Wied
@wied03
Mar 22 2016 21:46
@catmando - I suppose that depends. Personally I prefer Sprockets because 1) I like having only 1 packaging system in production and 2) I dislike NPM for mainly angry old man reasons. That said, I think @fkchang is right about being pro-webpack to an extent because it's undeniable that the 'energy' in the JS world is in the NPM (and thus webpack/browserify) ecosystem
Jesse Chavez
@JesseChavez
Mar 22 2016 21:49
did you guys check out https://github.com/shakacode/react_on_rails ? they are using webpack.
ylluminate
@ylluminate
Mar 22 2016 21:56
would be smart to get some benchmarks up (for volt or clearwater) on https://github.com/TechEmpower/FrameworkBenchmarks - could at least show that it hangs with raw js and get the word out more as well as be a nice little demonstration piece potentially
Mitch VanDuyn
@catmando
Mar 22 2016 21:56
@wied03 - so what can be done? are they really mutually exclusive? If I have an existing rails app, and want to use react.rb, could both webpack and sprockets co-exist, or would it be better to just document how to move your app into webpack land?
Forrest Chang
@fkchang
Mar 22 2016 22:23
@wied03 @catmando what I've done is what a few others have done where I use webpack to produce js that sprockets includes - that seems to be the best way to integrate the 2 systems. I believe people have tried to use webpack or browserify to replace sprockets altogether, that's only good if you only want to use npm, bower, whatever and nothing from the rails/gems world. I think that path throws out too much of the "baby with the bath water" - Rails is likely to always include sprockets, and so there will be assorted conveniences and integrations you may not want to give up. So I think the approach of using webpack to produce js that is included by sprockets gives you the best of both worlds, access to npm, retail all the built in sprockets goodness.
However, I suspect we will want to at least make it an option to have react.rb pull it's react.js from npm, I think letting npm handle the dependency tree is likely to be the most successful
Something else worth thinking is can we do opal compiles w/o sprockets? I dunno @elia or @meh have put any thoughts to that. At the moment, it seems like opal is not separatable from sprockets, which is another reason I feel the need to use webpack and sprockets, and since sprockets is baked into Rails, it's sort of a no brainer to me
Mitch VanDuyn
@catmando
Mar 22 2016 22:26
@fkchang - so my question remains given the scenario you described, can we make it so that you can specify all the dependencies in a single place (i.e. the Gemfile) that is read by something like webpack-bundler...
Forrest Chang
@fkchang
Mar 22 2016 22:27
@catmando so I haven't figured out how to do it that way, but in line with @elia 's suggestion, I did think that we should include some meta data in rubygems that we can somehow put into package.json for npm to resolve
Elia Schito
@elia
Mar 22 2016 22:28
@fkchang Opal::Builder is a compiling pipeline completely separated from sprockets
meh.
@meh
Mar 22 2016 22:28
@fkchang in ye olde times, we didn't use sprockets, and I personally hated when we started using it because it created all sorts of issues
Elia Schito
@elia
Mar 22 2016 22:30
btw @Mogztter was in the process of making Opal::Builder work under nodejs to have the complete thing available in a JS only env
Forrest Chang
@fkchang
Mar 22 2016 22:30
I want to call out that Rails is looking to integrate w/npm via https://teams.railsgirlssummerofcode.org/projects/93-ruby-on-rails i.e.
  • Integrate Rails with NPM by default

Right now in Ruby-based apps is possible to manage asset dependencies adding assets gems to Gemfile:

gem 'underscore-rails'
gem 'jquery-rails'
In order to have this working people have created a lot of Ruby gems to wrap most popular JS libraries (thus the *-rails suffix) but doing this and having to maintain gems periodically everytime a new version of JS library is release is a busy work and we would like to have better solution for this.

In Javascript-land package managers like Bower and NPM have been used for assets from some time ago but Ruby on Rails doesn't integrate with any of them by default right now.

NPM is not only the default package manager for Node.js, some full-stack frameworks like Laravel (PHP), Phoenix (Elixir), Play! (Scala) and some developments environments like Visual Studio (.NET), ember-cli (Ember.js) and angular-cli (AngularJS2) are using NPM for asset dependencies management and there are more than 250,000 packages published right now in NPM registry making it a great solution for assets management.

We want to integrate NPM with Rails by default, we understand that this could require adding Node.js as dependency for Rails development, we can investigate workarounds to avoid that (e.g creating a Ruby script reproducing the bare minimum required to do only "npm install").

Elia Schito
@elia
Mar 22 2016 22:31
@meh lately I was re-evaluating a separation between corelib/stdlib+parser and the rest btw
meh.
@meh
Mar 22 2016 22:32
elia, what's the idea?
Elia Schito
@elia
Mar 22 2016 22:33
duh, ehm, don't remember, but I was working on sprockets4… wait
I think it was being able to release updates to the core/stdlib/parser independently
Forrest Chang
@fkchang
Mar 22 2016 22:34
@elia so is it possible to setup a ruby based backend that will always serve the most recent assets the way sprockets does for Rails in development, but w/o sprockets?
Elia Schito
@elia
Mar 22 2016 22:35
…independently from the evolution of the building pipeline
Forrest Chang
@fkchang
Mar 22 2016 22:35
@Mogztter - how's the progress w/ Opal::Builder and node.js, I imagine success there could lead to better npm integration for Opal, whici s a big win, IMO
Elia Schito
@elia
Mar 22 2016 22:35
@meh e.g. 0.9 series could benefit from a bunch of the stuff on master without breaking anything, etc.
Forrest Chang
@fkchang
Mar 22 2016 22:36
but @catmando since Rails is looking to have some better integration w/npm, maybe we can leverage that or even be part of it
Elia Schito
@elia
Mar 22 2016 22:37
@fkchang subscribe to this opal/opal#1292 ;)
Mitch VanDuyn
@catmando
Mar 22 2016 22:37
@fkchang - great reference... but do we agree that it would be good to have all "dependencies" whether they are gems or .js packages in one file?
Forrest Chang
@fkchang
Mar 22 2016 22:39
@catmando if we can make it work 1 file, I'm for that, and as Rubyists, I lean towards it being in the gem, perhaps a 3rd is the one that pulls the metadata out of the gems, and then created the package.json so npm can install all the right things
I need to talk w/the rails core guy about what they're doing, it's an opportunity to outsource that work if we can come to a common agreement
that being said, I still need to go back and document what I did. Then I think I need to apply it to a few more projects to figure out what the pattern to be automated is, and what kind of config/customization we want to allow is
OH, and I want to try react hot loading (separate from webpack hot module reloading which was demoed here recently ) w/react.rb at one point and if it works, make that part of the webpack setup w/react.rb
Brady Wied
@wied03
Mar 22 2016 22:47
@fkchang @catmando - Shameless self plug but that Rails link mentioned testing JS. In part because I was not happy with the other options, a big chunk of karma-opal-rspec involves telling Karma about the sprockets dependency graph so that it can watch files and run tests. It's not webpack related, but just thought I would mention it as a case of integrating a pure JS tool with Sprockets
Sizeable chunks of it would not be needed if one had a pure webpack/NPM Rails project from a JS point of view
Forrest Chang
@fkchang
Mar 22 2016 22:51
@wied03 based on your karma-opal-rspec experience, you may know some of the things that I'd want to solve already, or be close to it
Forrest Chang
@fkchang
Mar 22 2016 22:56
1 future scenario I see is something like:we add react.rb X.Y to my rails project, from that gem we'll know that we need react.js 0.15.2 , and that gets inserted into package.json, so that we can know that we need other npm react components to be compatible w/0.15.*., react.rb X.Y will know that it gets it's react 0.15.2 from npm via webpack (which we may need to lock which version). Something will then have the rails project automatically update the npm derived js, so that sprockets always serves the most up to date versions of npm stuff, possibly other raw js stuff depending (which is pretty easy w/ webpack in watch mode) -- possibly serving up hot reloading, and on production we create that js as part of assets:precompile.
That's the rails scenario, more or less, but we'd have large amounts of reuse for any other backend, or so that's the theory
Elia Schito
@elia
Mar 22 2016 23:12
@/all I'm changing the compiler to add "use strict" to generated code, please let me know if you know of any case it can lead to problems
@/all also I changed the default setting for dynamic requires from error to warning at compile time and from warning to error at runtime to hove an experience more similar to what we have in CRuby
Brady Wied
@wied03
Mar 22 2016 23:19
@elia - Can you disable the warning at compile time and suppress the error at runtime? RSpec has lots of dynamic requires we can't easily remove
Elia Schito
@elia
Mar 22 2016 23:24
Actually the runtime errors only if the file to be required is missing, (which is btw a good reason to fix the config name) and at compile time I think warnings by default are fine, but they can easily suppressed by setting Opal::Config.dynamic_require_severity = :ignore
@wied03 ^