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

Allow specifying a group of opal gems to require from #38

Open
illogikal opened this issue Feb 17, 2017 · 1 comment
Open

Allow specifying a group of opal gems to require from #38

illogikal opened this issue Feb 17, 2017 · 1 comment

Comments

@illogikal
Copy link

I am developing an opal app with rack, and I have organized my gemfile like this.

gem 'normal gem'

group :opal, :development, :test, :production do
  gem 'opal gem'
  gem 'opal gem'
end

Tlhis alows me to easily and clearly specify which gems I want in my opal compilation.

https://github.com/cj/opal-webpack/blob/master/lib/getRubyMetadata.js#L22

  if (useBundler) {
    if (env.RAILS_ENV) {
      // using rails runner to try and take advantage of spring
      return bundlerExecute(`rails runner "${rubyCode}"`)
    }
    else {
      return bundlerExecute(`ruby -e "Bundler.require; ${rubyCode}"`)
      return bundlerExecute(`bundle exec ruby -e "Bundler.require(:opal); ${rubyCode}"`)
    }
  }

I have had to enable bundler to use opal, and have updated the line thusly
return bundlerExecute(`ruby -e "Bundler.require; ${rubyCode}"`)
to:
return bundlerExecute(`bundle exec ruby -e "Bundler.require(:opal); ${rubyCode}"`)
I added the bundle exec, because it was not working for me previously.

I think that setting a gemfile group is a good way to specify opal gems, and perhaps this could also become an opal-webpack config option?

@wied03
Copy link
Collaborator

wied03 commented Apr 8, 2017

Sorry, have had a lot going on. @cj - You still around?

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