Opal Ruby module loader for webpack
Last updated 4 years ago by ceej .
MIT · Original npm · Tarball · package.json
$ cnpm install opalrb-loader-cj 
SYNC missed versions from official npm registry.


Opal is a compiler for writing JavaScript in Ruby.

This package allows transpiling Ruby files using Opal and webpack.

Check out this blog post if you are interested in the project background.


npm install opalrb-loader --save-dev


Documentation: Using loaders

// webpack.config.js 
module: {
  loaders: [
      test: /\.rb?$/,
      loader: 'opalrb-loader'


See Opal::Compiler options for possible options.

// webpack.config.js 
module: {
  loaders: [
      test: /\.rb?$/,
      loader: 'opalrb-loader',
      query: {
        requirable: false,
        freezing: false,


By passing OPAL_LOAD_PATH environment variable to webpack, the loader will correctly resolve file other than relative path.

opalrb-loader is only bundled with compiler module. It left the decision on managing runtime, corelib or gems to developer.

See the example Rakefile for how to integrate using other Opal gems.

Compared to Opal::Builder

  • Relative require is correctly resolved.
  • require_trees is not yet implemented.
  • erb is not supported (which should be implemented as separate loader).

Known issues

  • First time compiling is relatively slow compared to Ruby one, use --watch option for webpack to speed up dev iteration.
  • Use require to load JS file is broken, but you can write as below to load JS module (webpack will correctly resolve it).
# Inside ruby file
`var $ = require("jquery")`
  • stdlib and some gems may not be correctly compiled, please file an issue if you encounter one.


It's under Examples folder.

  • simple: Basic setup without further dependency.
  • complex: Compile opal/corelib and other gems.


  • ./build_compiler.sh to build compiler
  • npm start to compile index.es6.js (Babel CLI is required)


David Chang @zetachang


Available under the MIT license. See the LICENSE file for more info.

Current Tags

  • 0.0.4                                ...           latest (4 years ago)

1 Versions

  • 0.0.4                                ...           4 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (7)
Dev Dependencies (0)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |