Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

opalrb-loader

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opalrb-loader

Opal Ruby module loader for webpack

  • 0.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

opalrb-loader

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.

Installation

npm install opalrb-loader --save-dev

Usage

Documentation: Using loaders

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

Options

See Opal::Compiler options for possible options.

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

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.

Examples

It's under Examples folder.

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

Development

  • npm install
  • npm run build_compiler to build compiler
  • npm start to compile & watch index.es6.js

Contact

David Chang @zetachang

License

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

Keywords

FAQs

Package last updated on 25 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc