Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is support for gatsby possible? #36

Open
hayley opened this issue Jul 16, 2016 · 8 comments
Open

is support for gatsby possible? #36

hayley opened this issue Jul 16, 2016 · 8 comments

Comments

@hayley
Copy link

hayley commented Jul 16, 2016

So I'll preface all of this with the fact that I'm basically completely new to webpack and js toolsets (my background is middleman/sprockets), but I'm wondering if it would be possible for opal-webpack to work with:
https://github.com/gatsbyjs/gatsby

I've got the repository with the non-working code here:
https://github.com/hayley/hayley.io

If I run just gatsby develop, mysteriously, Opal itself will load properly but I can't call 'reactrb'. If I do bundle exec gatsby develop, then I get the following error:

ERROR in ./~/opal-webpack?file=opal%2Fbase&cacheIdentifier=%7B%22opal-loader%22%3A%221.0.9%22%2C%22opal-compiler%22%3A%220.9.4%22%7D&requirable=true!/Users/hayley/.gem/ruby/2.3.1/gems/opal-0.9.4/opal/opal/base.rb
Module not found: Error: Cannot resolve module 'babel' in /Users/hayley/.gem/ruby/2.3.1/gems/opal-0.9.4/opal/opal
 @ ./~/opal-webpack?file=opal%2Fbase&cacheIdentifier=%7B%22opal-loader%22%3A%221.0.9%22%2C%22opal-compiler%22%3A%220.9.4%22%7D&requirable=true!/Users/hayley/.gem/ruby/2.3.1/gems/opal-0.9.4/opal/opal/base.rb 1:21-101

Is issue #7 related?

Oh and gatsby apparently handles webpack modifications through webpack configurator, in a file called gatsby-node.js/coffee.
Quick link to mine: https://github.com/hayley/hayley.io/blob/master/gatsby-node.coffee

@wied03
Copy link
Collaborator

wied03 commented Jul 17, 2016

#7 is sort of related. It looks like you're doing a require 'babel' from Ruby/Opal from the looks of that error. Not sure why you'd do that but if you did, you would want to manually add the Babel node module directory to the load path (see load path section of README). That's what #7 would make easier. That said, don't get why you'd need to require babel from Opal. It's almost as if you're using the React-rails package or something and you have more files going through Opal than you need to.

@hayley
Copy link
Author

hayley commented Jul 17, 2016

Yeah, it's got me stumped because I'm definitely not doing that. And it only happens when I do a bundle exec. My total guess is that bundler is somehow messing up the paths that gatsby is using to build its own things. So then gatsby's build process is looking for vanilla JS requirements in my gem directories.

@hayley
Copy link
Author

hayley commented Jul 17, 2016

So I'm trying to work around needing bundle exec.

I've read https://github.com/cj/opal-webpack/tree/master/examples/complex and it looks like the following is theoretically what I need to do, right?

require 'opal'
Opal.use_gem 'reactrb'

I'm getting this though:

Uncaught use_gem: undefined method `use_gem' for undefined

@wied03
Copy link
Collaborator

wied03 commented Jul 18, 2016

The examples are really out of date and this has almost been rewritten since then.

@wied03
Copy link
Collaborator

wied03 commented Jul 18, 2016

Are you using react-rails ?

@hayley
Copy link
Author

hayley commented Jul 19, 2016

No to react-rails.

If it helps, opal files themselves seem to compile just fine. It seems to basically be a problem of using bundle exec and requiring a library (e.g. require 'opal'). Which is why I'm thinking that bundler is somehow altering the paths that webpack uses in general.

I got things sort of working by calling reactrb-express (see https://github.com/hayley/hayley.io/blob/master/html.js), which bundles the following into one .js file:

gem 'rake'
gem 'opal'
gem 'opal-browser'
gem 'reactrb'
gem 'opal-jquery'

However, I'm assuming that in order to actually take advantage of gatsby being able to use rb files directly, I'm going to have to figure out how to get everything working through webpack.

Oh, not sure if related, but I also tried doing a require from one .rb file to another in the same directory and couldn't get it to work. I tried require_relative.

@wied03
Copy link
Collaborator

wied03 commented Jul 28, 2016

@hayley - Sorry. I've been slammed with other things and just haven't been able to spend time on this project lately.

@hayley
Copy link
Author

hayley commented Jul 31, 2016

Hey, no worries.

FYI, since @catmando mentioned opening stackoverflow questions for anything reactrb related, I opened http://stackoverflow.com/questions/38549955/is-it-possible-to-use-the-gatsby-static-site-generator-with-reactrb

I wish I knew more about webpack and such so I could directly help, but let me know if there's any info/help I can provide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants