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:
- Detect JS/TS project (presence of
package.json, *.js, *.ts)
- Install dependencies via npm/yarn/pnpm
- If TypeScript, transpile to JavaScript
- Use jco to create user code layer
- 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:
- Run TypeScript compiler
- 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
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
User runs
fabricks buildand gets a working WASM component.Implementation
1. JavaScript build toolchain integration
When
[from].imagereferences a Node runtime:package.json,*.js,*.ts)2. Build official Node base images
Create and publish to fabricks.dev registry:
fabricks.dev/runtimes/node:18fabricks.dev/runtimes/node:20fabricks.dev/runtimes/node:22Base image contains:
3. WIT interface generation
For JavaScript HTTP services, generate appropriate WIT bindings:
wasi:http/proxyfor HTTP serviceswasi:cli/commandfor CLI tools4. Dependency handling
Support for
package.json:5. TypeScript support
If
tsconfig.jsonpresent or.tsentrypoint:Example JavaScript MCP Server
Files to Create/Modify
fabricks/src/commands/build.rs- JavaScript detection and build flowfabricks/src/build/javascript.rs- JS-specific build logic (new)New Dependencies
jco(CLI tool, invoked during build)esbuildortscfor bundling/transpilationAcceptance Criteria
fabricks buildworks for JavaScript projects with[from].imagefabricks buildworks for TypeScript projectspackage.jsondependencies are bundledwasi:http/proxyexamples/directory