FFFF GitHub - miyakhelwaleedahmad/smelt · GitHub
[go: up one dir, main page]

Skip to content
miyakhelwaleedahmadPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

1,529 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SMELT

Smelt your TypeScript and Python into Rust.

crates.io license

Install the smelt CLI from crates.io:

cargo install --locked smelt-transpiler

smelt is a transpiler that takes strictly-typed TypeScript and Python source code and compiles it down to idiomatic Rust. The goal is not to transpile all TS/Python — it is to transpile the statically-typed subset where types actually mean something.

Why

TypeScript and Python both have rich, expressive type systems that are mostly used for editor tooling and runtime validation. smelt takes those types seriously: if your code is fully typed and passes strict checks, smelt can lower it through a shared intermediate representation and emit Rust that compiles, runs, and is reasonably idiomatic.

The long-term vision is language-interchangeable modules: a Python file importing from a TypeScript file, both lowering to the same HIR, both becoming the same Rust crate.

Status

Pre-alpha. See the milestones in github issues for the v1.0 roadmap.

Current external test milestone: Smelt can compile the focused date-fns/date-fns quartersToMonths slice, including its Vitest test file, into a generated Rust crate whose cargo test run passes. The probed files are:

  • src/constants/index.ts
  • src/quartersToMonths/index.ts
  • src/quartersToMonths/test.ts

This is the first real third-party TypeScript test slice where source-language tests lower into native Rust #[test] functions and pass under Cargo.

Installation

Install the smelt CLI from the smelt-transpiler package on crates.io:

cargo install --locked smelt-transpiler
smelt --help

The default installation includes the TypeScript and Python frontends, with ty support enabled for Python.

Publishing to crates.io is handled by scripts/publish-crates.sh (--execute to publish for real; a bare run does a dry run). It publishes the crates leaf-first, including smelt-py-types before the Python frontend. Maintainers can also run the manual Publish crates.io release workflow after committing the new workspace version. The crates-io GitHub environment must provide a CRATES_IO_TOKEN secret; the dispatch requires the matching version and the confirmation text publish.

v1.0 Goals

  • A real Express app (TypeScript, strict mode) compiles to a working axum server.
  • A real FastAPI app (Python, fully typed, passes ty) compiles to a working axum server.
  • Both produce structurally similar Rust output, validating the shared HIR design.
  • Configuration via Smelt.toml, CLI modeled after cargo.

Non-Goals (for v1.0)

  • LSP / editor integration.
  • Ownership/borrow inference (v1.0 clones aggressively).
  • Supporting dynamic features (eval, getattr, monkey-patching, any).
  • Multiple Rust web framework backends. v1.0 targets axum only.
  • Incremental compilation.

Architecture at a Glance

TypeScript ──┐                                      ┌── Rust source
             ├──> Frontend ──> HIR ──> MIR ──> Codegen
Python ──────┘                                      └── Cargo.toml (generated)

See specs/architecture.md for the full picture.

Documentation

Repository Layout

The full workspace member list is in Cargo.toml; the crates below are the core transpiler pipeline.

crates/
  smelt-frontend-ts/    TypeScript parser → HIR
  smelt-frontend-py/    Python parser → HIR
  smelt-hir/            High-level IR types and validation
  smelt-mir/            Mid-level IR (SSA-ish, ownership-naive)
  smelt-codegen-rust/   MIR → Rust source
  smelt-runtime/        Runtime helpers that transpiled code depends on
  smelt-transpiler/     The `smelt` binary
specs/                  Design documents
examples/               Example projects (examples/typescript, examples/python)

License

GNU General Public License v3.0

AI use

This project leans heavily on AI, and that now includes the code. A large portion of the source is AI-generated — as are commit messages, issues, and documentation (READMEs, design docs, comments). AI-generated PRs are welcome as long as they stay reasonably sized and make sense. Human review and the test suite are the quality gate: anything that lands has to build, pass cargo test/clippy, and be understandable.

Contributing

Fork the repo and submit a pr :)

Coverage

Coverage

Workspace

Metric Coverage
Functions 85.62%
Lines 80.11%
Regions 75.72%
Branches 67.81%

Per Crate

Crate Functions Lines Branches
smelt-asyncio 100.00% 81.82% 0.00%
smelt-codegen-rust 89.34% 84.61% 67.03%
smelt-frontend-py 82.87% 76.80% 69.37%
smelt-frontend-ts 86.37% 78.93% 67.97%
smelt-hir 81.62% 54.07% 67.86%
smelt-mir 83.18% 82.61% 71.22%
smelt-py-types 80.00% 89.55% 72.22%
smelt-python 100.00% 100.00% 0.00%
smelt-runtime 96.84% 99.25% 90.00%
smelt-specialize 65.18% 73.06% 58.52%
smelt-stdlib 91.24% 81.02% 92.14%
smelt-test 91.13% 90.26% 61.36%
smelt-transpiler 76.15% 74.87% 62.30%

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0