Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

A Gleam WASM runner that allows executing Gleam code dynamically using WebAssembly.

License

Notifications You must be signed in to change notification settings

Comamoca/subaru

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Last commit Repository Stars Issues Open Issues Bug Issues

eyecatch

subaru

A Gleam WASM runner that allows executing Gleam code dynamically using WebAssembly.



Quote

πŸš€ How to use

# Using installed version (after deno install)
subaru example.gleam
subaru --code 'import gleam/io
pub fn main() { io.println("Hello from WASM!") }'

# Using direct URL execution
deno run --allow-all https://github.com/Comamoca/subaru/raw/main/src/cli.ts example.gleam

# Using local development version
deno task cli example.gleam
deno task cli --code 'import gleam/io
pub fn main() { io.println("Hello from WASM!") }'

# Execute remote script
subaru --url https://example.com/script.gleam
  • Execute Gleam files directly without compilation
  • Run Gleam code from strings, files, or remote URLs
  • Dynamic compilation using Gleam's WebAssembly compiler
  • Worker-based execution for safe code isolation
  • Configurable logging and debug output
  • Preloaded Standard Libraries - Automatic access to essential Gleam modules
  • Echo Keyword Support - Full support for Gleam v1.11.0's debugging features

⬇️ Install

Prerequisites

  • Deno - Modern runtime for JavaScript and TypeScript
  • Gleam - For local Gleam development (optional)

Using deno install (Recommended)

# Install globally
deno install --allow-all -n subaru https://github.com/Comamoca/subaru/raw/main/src/cli.ts

# Run from anywhere
subaru --help
subaru example.gleam
subaru --code 'import gleam/io
pub fn main() { io.println("Hello!") }'

Direct URL execution

# Run directly from GitHub without installation
deno run --allow-all https://github.com/Comamoca/subaru/raw/main/src/cli.ts --help

# Execute Gleam code
deno run --allow-all https://github.com/Comamoca/subaru/raw/main/src/cli.ts --code 'import gleam/io
pub fn main() { io.println("Hello from URL!") }'

From GitHub (Local Development)

# Clone repository
git clone https://github.com/Comamoca/subaru
cd subaru

# Setup (download Gleam WASM compiler)
deno task setup

# Run CLI
deno task cli --help

From Source

git clone https://github.com/Comamoca/subaru
cd subaru
deno task setup

⛏️ Development

# Using Nix (recommended)
nix develop

# Or with direnv
direnv allow

# Manual setup
deno task setup

# Development commands
deno task dev        # Setup and run development environment
deno task test       # Run all tests
deno task example    # Run usage examples
deno task fmt        # Format code
deno task lint       # Lint code
deno task check      # Type check

Preloaded Libraries Usage Example

All these libraries are automatically available without imports:

import gleam/io
import gleam/list
import gleam/string
import gleam/int
import gleam/result

pub fn main() {
  // List operations
  [1, 2, 3, 4, 5]
  |> list.map(fn(x) { x * 2 })
  |> echo  // [2, 4, 6, 8, 10]
  |> list.filter(fn(x) { x > 5 })
  |> echo  // [6, 8, 10]
  
  // String operations
  "Hello, Gleam!"
  |> string.uppercase()
  |> io.println()  // HELLO, GLEAM!
  
  // Result operations
  let result = case int.parse("42") {
    Ok(num) -> "Parsed: " <> int.to_string(num)
    Error(_) -> "Parse failed"
  }
  io.println(result)  // Parsed: 42
}

πŸ“ Todo

  • Add more comprehensive error handling
  • Implement module caching for better performance
  • Add support for custom Gleam compiler versions
  • Create VSCode extension for Gleam WASM execution
  • Add streaming execution for large outputs
  • Implement code completion and syntax highlighting
  • Add benchmark suite for performance testing
  • Support for additional output formats (JSON, XML, etc.)

πŸ“œ License

MIT License - see LICENSE file for details.

This project is open source and available under the MIT License.

🧩 Modules

TypeScript/Deno Dependencies

  • Deno Standard Library - File system, path utilities, testing
  • Gleam WASM Compiler - Dynamic Gleam compilation to JavaScript

Preloaded Gleam Libraries

Development Environment

  • Nix Flakes - Reproducible development environment management
  • devenv - Development shell configuration and tooling
  • pre-commit hooks - Security scanning (git-secrets, ripsecrets)
  • treefmt - Automated code formatting across languages

πŸ‘ Affected projects

  • Gleam Language - Functional language for building type-safe systems that inspired this project
  • Deno - Modern runtime that enabled TypeScript-first development
  • WebAssembly - Binary instruction format that makes dynamic compilation possible

πŸ’• Special Thanks

  • Gleam Team - For creating an amazing functional language with excellent WASM support
  • Deno Team - For providing a fantastic development experience with TypeScript
  • WebAssembly Community - For enabling dynamic compilation and safe execution in browsers
  • Nix Community - For reproducible development environments and excellent tooling
  • Open Source Contributors - For all the libraries and tools that made this project possible

About

A Gleam WASM runner that allows executing Gleam code dynamically using WebAssembly.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

  •  

Packages

No packages published

Contributors 2

  •  
  •  

Languages