Registry / serialization / opal-compiler

opal-compiler

JSON →
library3.0.0jsnpmunverified

Transpile Ruby code to JavaScript in Node.js using the Opal Ruby-to-JS compiler. Current stable version 3.0.0 is based on Opal 1.7.3 and requires Node >=16. Release cadence is irregular. Unlike browser-focused Opal builds, this package provides a Node-native API (Builder) to compile Ruby files programmatically. Key differentiator: direct Node.js integration with no separate runtime required, supporting modern ESM patterns in v3.

npm install opal-compiler
INSTALL
IMPORT
SIG · OPAL-COMPILER
O
opal-compiler
serializationjavascriptv3.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Builder
import { Builder } from 'opal-compiler'
const Builder = require('opal-compiler').Builder
ESM-only since v3; CJS require still works but is deprecated.
default (Opal global)
import 'opal-compiler'
const Opal = require('opal-compiler')
The Opal global is automatically set; direct import without binding is sufficient.
Builder.create
Builder.create()
new Builder()
Builder.create() is a static factory; constructor is not exposed.

Transpile a Ruby file to JavaScript and print the compiled output.

import { Builder } from 'opal-compiler'; const builder = Builder.create(); const result = builder.build('hello.rb').toString(); console.log(result);
Debug
Known issues
breakingv3.0.0 drops support for Node <16; older versions will fail.
fix
Upgrade Node.js to >=16.
affects: <3.0.0
breakingESM-only imports in v3; CommonJS require is deprecated.
fix
Use import syntax or enable ESM in your project.
affects: >=3.0.0
deprecatedBuilder.create() in v2 used a different constructor signature.
fix
Use the current Builder.create() API as documented.
affects: >=2.0.0 <3.0.0
gotchaOpal global is auto-set; do not assign it manually.
fix
Simply import the package; Opal is available on window/globalThis.
affects: >=1.0.0
gotchaBuild result may need Opal runtime to execute; ensure opal package is installed.
fix
Install opal as a dependency (npm install opal).
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Builder is not a constructor
Using new Builder() instead of Builder.create()
fix
Use Builder.create() static factory method.
Error: Cannot find module 'opal-compiler'
Package not installed or wrong import path
fix
Run 'npm install opal-compiler' and ensure import/require path matches.
Opal is not defined
Opal global not set, possibly because package not imported or CJS/ESM mismatch
fix
Import the package at top level (import 'opal-compiler' or require('opal-compiler')) before using Opal.
Error: 'require.resolve.paths' is not a function
Using a very old Node version (<16) with v3
fix
Upgrade Node to >=16.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
opaloptionalRuntime library for Opal compiled code
Agent activity
2 hits · last 30 days
node
2
Resources
opal-compiler — npm install opal-compiler · libregistry