moonbit-js-binding

Bridge MoonBit with JavaScript bindings for typed FFI interop.

320|3|Updated Apr 24, 2026
One-click install
npx skills add https://github.com/mizchi/skills --skill moonbit-js-binding
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: moonbit-js-binding
Source: https://github.com/mizchi/skills/tree/main/lang/moonbit-js-binding
Command: npx skills add https://github.com/mizchi/skills --skill moonbit-js-binding

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes assets (resource) and references (resource) components.

What problem does it solve?

MoonBit bindings to JavaScript enable safe, typed interop at the JS boundary, reducing boilerplate for cross-language projects.

Core Features & Use Cases

  • Inline extern "js" bindings using #| blocks for small, deterministic JS snippets.
  • Module-based access with #module to bind named exports from node/npm packages.
  • JsValue interop with get/set/call_method helpers to interact with arbitrary JS objects.
  • Promise bridging patterns for async MoonBit functions via the provided suspend / wait APIs.
  • Example project in assets showcasing a TS-friendly build and TypeScript declarations.

Quick Start

Create a MoonBit skill that binds a small JS API and run moon test to verify the FFI boundary.

Frequently Asked Questions about moonbit-js-binding

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I bind MoonBit to JavaScript for typed interop?

MoonBit binds to JavaScript for typed interop using inline extern 'js' blocks for small snippets and #module-based exports for named npm packages. This provides safe FFI across the JS boundary.

Can I use MoonBit FFI with Node and browser environments?

MoonBit JavaScript bindings apply to both browser and Node environments. You can use JsValue interop with get, set, and call_method helpers to safely interact with arbitrary JS objects across either platform.

How do I handle async JavaScript Promise bridging in MoonBit?

JavaScript Promise bridging in MoonBit uses provided suspend and wait APIs to handle async patterns. This allows packaging asynchronous MoonBit functions to work seamlessly with JavaScript Promise objects.

What is the best way to expose MoonBit APIs to TypeScript?

Exposing MoonBit APIs to TypeScript is best done using #module-based exports to package the API. The provided example project in assets showcases a TS-friendly build that generates TypeScript declarations.

How do I test MoonBit JavaScript FFI boundaries?

You test MoonBit JavaScript FFI boundaries by creating a small MoonBit skill that binds a JS API and running moon test. This verifies the extern 'js' blocks and JsValue interop function correctly.

Do I need external dependencies to use MoonBit JavaScript bindings?

No external dependencies are required to use MoonBit JavaScript bindings. The FFI mechanism relies on built-in extern 'js' blocks, #module exports, and JsValue interop helpers native to the MoonBit toolchain.