Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@camertron/opal-esm

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@camertron/opal-esm

The Opal runtime, packaged as a series of ESM modules.

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

@camertron/opal-esm

Unit Tests

What is this thing?

This package contains a copy of the Opal runtime, packaged as a series of ESM modules. Opal is normally evaluated directly on the page and thus attaches itself to window. This library prevents that behavior and instead allows importing and creating locally-scoped instances of the runtime.

Usage

Import Opal using a standard ESM import statement:

import { Opal } from "@camertron/opal-esm";

Opal.Kernel.$puts("Hello, world!");

Importing stdlib modules

Opal includes an implementation of the Ruby standard library. To make these modules available to your ES module, all you have to do is import them.

import { Opal } from "@camertron/opal-esm";
import "@camertron/opal-esm/base64"

Opal.require("base64");

const base64_module = Opal.Kernel.$const_get("Base64");
const encoded = Opal.send(base64_module, "encode64", ["foobar"]);

console.log(encoded)  // prints "Zm9vYmFy\n"

Isolation

Note that, although opal-esm allows the Opal runtime to be imported without modifying window, separate imports do not create more than one copy of the Ruby runtime. All requires, etc affect the same execution context.

Running Tests

npm test should do the trick.

License

Licensed under the MIT license. See LICENSE for details.

Authors

  • Cameron C. Dutro: http://github.com/camertron

Keywords

ruby

FAQs

Package last updated on 24 Apr 2026

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