Skip to main content
JavaScript reaches WebAssembly through ComponentizeJS, driven by the jco CLI. Your module is bundled with the StarlingMonkey JavaScript runtime into a single WASI Preview 2 component.

Prerequisites

  • Node.js 18 or newer, with npm.
  • The Noorle CLI.
  • The shared WebAssembly tools, installed once with noorle plugin prepare.

Layout

The interface

This example returns a JSON string, which keeps the JavaScript side to plain objects.

The implementation

Export a function per WIT export. WIT’s kebab-case names map to camelCase in JavaScript, so check-weather is implemented as checkWeather.
Two things the runtime gives you:
  • fetch() works. StarlingMonkey implements it over WASI HTTP, so ordinary fetch calls go out through the host — subject to the host allowlist in noorle.yaml.
  • Environment access is an import. getEnvironment() from wasi:cli/environment returns the key/value pairs you allowed, and nothing else.
Exported functions may be async; the component model call is driven to completion for you.

package.json

"type": "module" is required — ComponentizeJS consumes ES modules.

noorle.yaml

Same shape in every language. Full key-by-key reference: noorle.yaml.

Build

That runs the project’s build.sh, which installs dependencies, fetches the WIT dependencies, and componentizes:

Test locally

Deploy

Next