{"id":26045,"library":"opal-compiler","title":"Opal Compiler","description":"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.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"git://github.com/mogztter/opal-node-compiler","tags":["javascript","opal","compiler","ruby"],"install":[{"cmd":"npm install opal-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add opal-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add opal-compiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime library for Opal compiled code","package":"opal","optional":true}],"imports":[{"note":"ESM-only since v3; CJS require still works but is deprecated.","wrong":"const Builder = require('opal-compiler').Builder","symbol":"Builder","correct":"import { Builder } from 'opal-compiler'"},{"note":"The Opal global is automatically set; direct import without binding is sufficient.","wrong":"const Opal = require('opal-compiler')","symbol":"default (Opal global)","correct":"import 'opal-compiler'"},{"note":"Builder.create() is a static factory; constructor is not exposed.","wrong":"new Builder()","symbol":"Builder.create","correct":"Builder.create()"}],"quickstart":{"code":"import { Builder } from 'opal-compiler';\nconst builder = Builder.create();\nconst result = builder.build('hello.rb').toString();\nconsole.log(result);","lang":"typescript","description":"Transpile a Ruby file to JavaScript and print the compiled output."},"warnings":[{"fix":"Upgrade Node.js to >=16.","message":"v3.0.0 drops support for Node <16; older versions will fail.","severity":"breaking","affected_versions":"<3.0.0"},{"fix":"Use import syntax or enable ESM in your project.","message":"ESM-only imports in v3; CommonJS require is deprecated.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use the current Builder.create() API as documented.","message":"Builder.create() in v2 used a different constructor signature.","severity":"deprecated","affected_versions":">=2.0.0 <3.0.0"},{"fix":"Simply import the package; Opal is available on window/globalThis.","message":"Opal global is auto-set; do not assign it manually.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Install opal as a dependency (npm install opal).","message":"Build result may need Opal runtime to execute; ensure opal package is installed.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use Builder.create() static factory method.","cause":"Using new Builder() instead of Builder.create()","error":"TypeError: Builder is not a constructor"},{"fix":"Run 'npm install opal-compiler' and ensure import/require path matches.","cause":"Package not installed or wrong import path","error":"Error: Cannot find module 'opal-compiler'"},{"fix":"Import the package at top level (import 'opal-compiler' or require('opal-compiler')) before using Opal.","cause":"Opal global not set, possibly because package not imported or CJS/ESM mismatch","error":"Opal is not defined"},{"fix":"Upgrade Node to >=16.","cause":"Using a very old Node version (<16) with v3","error":"Error: 'require.resolve.paths' is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}