Skip to content

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

Description

@illogikal

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions