{"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,"search_vec":"'1.7.3':26 '16':30 '3.0.0':21 'api':48 'base':23 'browser':37 'browser-focus':36 'build':40 'builder':49 'cadenc':32 'code':5 'compil':2,17,51,73 'current':18 'differenti':56 'direct':57 'esm':67 'file':53 'focus':38 'integr':59 'irregular':34 'javascript':7,71 'js':16 'key':55 'modern':66 'nativ':47 'node':29,46 'node-n':45 'node.js':9,58 'opal':1,12,25,39,72 'packag':42 'pattern':68 'programmat':54 'provid':43 'releas':31 'requir':28,64 'rubi':4,14,52,74 'ruby-to-j':13 'runtim':63 'separ':62 'stabl':19 'support':65 'transpil':3 'unlik':35 'use':10 'v3':70 'version':20","created_at":"2026-05-01T13:47:54.686074+00:00","updated_at":"2026-05-01T13:47:54.686074+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":"https://opalrb.com","github":"https://github.com/mogztter/opal-node-compiler","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/opal-compiler","openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-05-01","next_check":"2026-07-30","install_tag":null}}