balmoral / opal-highcharts

Ruby wrapper for Highcharts and Highstock javascript libraries
MIT License
5 stars 2 forks source link

Opal 0.10.2 #1

Closed barriehadfield closed 7 years ago

barriehadfield commented 7 years ago

Hello - I am having issues with OpalHighcharts with Opal > 0.10.x

opal-highcharts (= 0.1.2) was resolved to 0.1.2, which depends on opal (< 0.9.0, >= 0.8.0)

If I remove the Opal version dependency, I can bundle OK but I get a sprockets error couldn't find file 'opal-highcharts' with type 'application/javascript' when loading the page

Is there anything I need to change in order to support later Opal versions?

Any help much appreciated.

cc @balmoral

balmoral commented 7 years ago

I took the dependency out on my fork too.

Using Opal 0.11.0.dev with the following Gemfile entries all seems to be working:

gem 'opal', :git => 'https://github.com/opal/opal' # 0.11.0.dev
gem 'opal-sprockets', :git => 'https://github.com/opal/opal-sprockets' # for >= 0.11

The Opal sprockets stuff is all a bit of a mystery to me, but this works for me.

Good to hear opal-highcharts is being used - is it a serious project?

barriehadfield commented 7 years ago

Hi - thanks so much for the reply. I will give that a go. Yes, its a serious project but internal only - it relies a great deal on Highcharts and using it from within Opal code is fantastic! Thanks so much for the gem!

barriehadfield commented 7 years ago

Sorry, same issue with Opal 0.11.0

Using opal 0.11.0.dev from https://github.com/opal/opal (at master@bdd75b3) Using opal-sprockets 0.4.0.0.11.dev.3.1.beta1 from https://github.com/opal/opal-sprockets (at master@acc7fff) Using opal-highcharts 0.1.2

I get couldn't find file 'opal-highcharts' with type 'application/javascript' in the browser

component.rb is here:

require 'opal'
require 'opal-highcharts'
require 'webpack/client_and_server.js'
require 'reactrb/auto-import'
require 'hyper-react'
if React::IsomorphicHelpers.on_opal_client?
  # add any additional requires that can ONLY run on client here
  require 'opal-jquery'
  require 'browser'
  require 'browser/interval'
  require 'browser/delay'
  require 'hyper-mesh/pusher'
end
require 'hyper-router'
require 'hyper-mesh'
require '_react_public_models'
require_tree './components'
barriehadfield commented 7 years ago

@balmoral I have managed to get past this by compiling Opal-Highcharts using Opal 0.10.2 and then including the output JS file. I have no idea why the require is not working!

This is a great gem - thanks for all the hard work.

balmoral commented 7 years ago

Apologies for delay - haven't been at screen for a bit.

Just looked at your code more closely.

Try require 'opal/highcharts - slash not dash.

Thanks for the compliment, though the Opal native support makes it pretty straightforward to wrap JS libraries.

I did enough to cover the basics and get started, so feel free to contribute anything more you'd find useful. I'm still really just playing with it.

Hope the above fixes your problem, otherwise don't know what to suggest. Sprockets etc not my area of expertise. Though if other Opal gems are loading for you, I can take a look at them and see if they're doing anything opal aware.

PS - I see you're very involved with Hyperloop. Lots of good stuff happening there, but I'm reluctant to get sucked into Rails. So for know sticking with clearwater and/or opal-browser, but keeping an open mind!

barriehadfield commented 7 years ago

Thank you very much @balmoral require 'opal/highcharts' did the trick! Is this due to a change in Opal > 0.10.0?

Yes, love being involved with Hyperloop and I am from the Rails world so it makes sense. We have been discussing moving Hyperloop on a bit so the link to Rails might not always be there. Clearwater looks great but I have not coded there yet. Go Isomorphic Ruby go!

PS: I am happy to issue a PR for the opal/highcharts fix (just a change to the docs) but will wait for your reasoning.

Thanks again

balmoral commented 7 years ago

It's always been that way, I just didn't notice your require when you raised the issue. Apologies. And apologies for the misleading docs too.

My recollection is that there may have been a convention to have opal gems named as 'opal-gem_name' and required as 'opal/gem_name'. But maybe I just made that up!

I'll admit it's confusing as it is so let me know whether you think it worth changing the gem to match the docs or just change the docs.

barriehadfield commented 7 years ago

NP - I think it's best to just update the docs. I am happy to do a PR if that helps?

Also, I think you need to push the updated gem to rubygems as the version there still has the Opal dependancy:

opal-highcharts (= 0.1.2) was resolved to 0.1.2, which depends on
      opal (< 0.9.0, >= 0.8.0)
balmoral commented 7 years ago

Easy for me to fix the the docs and push the gem.

Thanks.