2026-01-28 21:59:04 -05:00
2026-01-28 20:58:26 -05:00
2026-01-28 21:59:04 -05:00
qip
2026-01-27 12:55:55 -05:00
2026-01-28 21:59:04 -05:00
2026-01-27 09:56:40 -05:00
asd
2026-01-27 16:31:05 -05:00
2026-01-28 21:55:20 -05:00
2026-01-28 21:55:20 -05:00
asd
2026-01-27 16:31:05 -05:00

Poiesis

A Go tool that transpiles TypeScript to JavaScript using esbuild and executes it with goja, with an extensible builtin system.

Project Structure

reichard.io/poiesis/
├── cmd/
│   └── poiesis/                    # CLI application entry point
│       └── main.go
├── internal/
│   └── runtime/
│       ├── pkg/
│       │   └── builtin/            # Builtin framework (framework only)
│       │       └── builtin.go     # Registration system & type conversion
│       ├── standard/               # Standard builtin implementations
│       │   ├── fetch.go           # HTTP fetch builtin
│       │   └── fetch_test.go      # Tests for fetch
│       ├── runtime.go              # Transpilation & execution
│       └── runtime_test.go         # Runtime tests

Architecture

The project is cleanly separated into three packages:

  1. internal/runtime/pkg/builtin - The framework for registering builtins and type conversion

    • Generic registration with automatic type inference
    • Bidirectional Go ↔ JavaScript type conversion
    • No builtin implementations (pure framework)
  2. internal/runtime/standard - Standard builtin implementations

    • fetch, add, greet
    • Custom type converters for complex types
    • Independent and easily extensible
  3. internal/runtime - Runtime management

    • TypeScript transpilation with esbuild
    • JavaScript execution with goja
    • Automatically imports and registers standard builtins

Installation & Build

go build ./cmd/poiesis

Testing

go test ./...
golangci-lint run

Usage

poiesis <typescript-file>

Builtin System

The builtin system allows you to easily expose Go functions to TypeScript/JavaScript.

Adding a Builtin

Just write a Go function and register it:

// Your function
func add(a, b int) int {
    return a + b
}

// Register it
func init() {
    builtin.RegisterBuiltin("add", add)
}

That's it! The framework automatically:

  • Converts TypeScript values to Go types
  • Handles errors (panics as JS errors)
  • Generates TypeScript definitions
  • Manages the goja integration

Example

// TypeScript code
console.log("5 + 10 =", add(5, 10));

const response = fetch("https://httpbin.org/get");
console.log("OK:", response.ok);
console.log("Status:", response.status);
console.log("Body:", response.text());

Built-in Functions

  • fetch(url, options?) - HTTP requests
  • add(a, b) - Simple arithmetic example
  • greet(name) - String manipulation example

Dependencies

  • github.com/evanw/esbuild/pkg/api - TypeScript transpilation
  • github.com/dop251/goja - JavaScript execution
  • github.com/stretchr/testify/assert - Test assertions
Description
No description provided
Readme 107 KiB
Languages
Go 98.6%
Nix 1.4%