Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/ggrossetie/opal-node-compiler

Opal Compiler for Node.js
https://github.com/ggrossetie/opal-node-compiler

compiler javascript nodejs opal

Last synced: 4 months ago
JSON representation

Opal Compiler for Node.js

Lists

README

        

# Opal Compiler for Node.js

[![Build](https://github.com/Mogztter/opal-node-compiler/workflows/Build/badge.svg)](https://github.com/Mogztter/opal-node-compiler/actions?query=workflow%3ABuild)
[![npm version](http://img.shields.io/npm/v/opal-compiler.svg)](https://www.npmjs.org/package/opal-compiler)

Transpile Ruby code to JavaScript in JavaScript!

## Usage

Given a Ruby file named `hello.rb`:

```ruby
puts "Hello world"
```

The following code will transpile `hello.rb` to JavaScript:

```javascript
const Builder = require('opal-compiler').Builder
// Opal object will be available on the global scope

const builder = Builder.create()
const result = builder.build('hello.rb').toString()
console.log(result)
//(function(Opal) {
// var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice;

// Opal.add_stubs(['$puts']);
// return self.$puts("Hello world")
//})(Opal);
```