Skip to content

JavaScript/TypeScript runtime support via jco #22

@richardkiene

Description

@richardkiene

Parent Issue

#19 - Multi-language runtime support via base images

Depends On

#20 - Multi-layer OCI manifest support for base images

Overview

Enable JavaScript and TypeScript code to run in Fabricks by integrating jco (JavaScript Component Tools) and publishing official Node.js-compatible base images.

Target User Experience

[from]
image = "fabricks.dev/runtimes/node:20"

[source]
path = "."
entrypoint = "server.js"

[capabilities.network]
listen = [8080]

User runs fabricks build and gets a working WASM component.

Implementation

1. JavaScript build toolchain integration

When [from].image references a Node runtime:

  1. Detect JS/TS project (presence of package.json, *.js, *.ts)
  2. Install dependencies via npm/yarn/pnpm
  3. If TypeScript, transpile to JavaScript
  4. Use jco to create user code layer
  5. Compose with base runtime layer

2. Build official Node base images

Create and publish to fabricks.dev registry:

  • fabricks.dev/runtimes/node:18
  • fabricks.dev/runtimes/node:20
  • fabricks.dev/runtimes/node:22

Base image contains:

  • JavaScript engine compiled to WASM (StarlingMonkey or QuickJS)
  • Node.js-compatible APIs (subset)

3. WIT interface generation

For JavaScript HTTP services, generate appropriate WIT bindings:

  • wasi:http/proxy for HTTP services
  • wasi:cli/command for CLI tools

4. Dependency handling

Support for package.json:

[source]
path = "."
entrypoint = "server.js"
# package.json auto-detected, npm install run automatically

5. TypeScript support

If tsconfig.json present or .ts entrypoint:

  1. Run TypeScript compiler
  2. Use compiled JS for componentization

Example JavaScript MCP Server

// server.js
import { Server } from "@anthropic/mcp";

const server = new Server("my-mcp-server");

server.tool("hello", { name: "string" }, ({ name }) => {
  return `Hello, ${name}!`;
});

server.run();
# Fabrickfile
[from]
image = "fabricks.dev/runtimes/node:20"

[info]
name = "my-mcp-server"
type = "http"

[source]
entrypoint = "server.js"

[capabilities.network]
listen = [8080]

Files to Create/Modify

  • fabricks/src/commands/build.rs - JavaScript detection and build flow
  • fabricks/src/build/javascript.rs - JS-specific build logic (new)
  • New repo or directory for base image builds

New Dependencies

  • jco (CLI tool, invoked during build)
  • Optionally esbuild or tsc for bundling/transpilation

Acceptance Criteria

  • fabricks build works for JavaScript projects with [from].image
  • fabricks build works for TypeScript projects
  • Node base images published to fabricks.dev
  • package.json dependencies are bundled
  • HTTP services work with wasi:http/proxy
  • Example JavaScript service in examples/ directory

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions