11# ES-Runtime
2+
23V8-based ECMAScript runtime, WinterTC-compliant, I/O-injectable, capability-secured.
34
5+ ** Website & docs → [ esrun.opentechf.org] ( https://esrun.opentechf.org ) **
6+
47It ships in two shapes from the same core:
58
69- ** Embeddable library** (` es-runtime ` ) — a driven (tick/poll) runtime with
710 all I/O injected via provider traits and V8 kept behind an engine abstraction.
811- ** Standalone CLI** (` esrun ` ) — a thin binary that wires the default tokio
912 providers and runs JavaScript files end-to-end.
1013
11- ## Quick start (run JavaScript)
14+ ## Install
1215
13- ** Install** the latest release — downloads a prebuilt binary and verifies its
14- checksum.
16+ A prebuilt, checksum-verified binary:
1517
1618Linux / macOS:
1719
@@ -25,64 +27,68 @@ Windows (PowerShell):
2527irm https://raw.githubusercontent.com/Open-Tech-Foundation/ES-Runtime/main/install.ps1 | iex
2628```
2729
28- Or ** build once** from source (npm-script-style alias; produces a single
29- self-contained binary at ` target/release/esrun ` — no extra files or asset
30- directory needed):
30+ Or build from source — a single self-contained binary at ` target/release/esrun ` ,
31+ no extra files or asset directory:
3132
3233``` sh
33- cargo build-cli # alias for : cargo build --release -p es-runtime -cli
34+ cargo build --release -p es-runtime-cli # or the alias: cargo build-cli
3435```
3536
36- ** Then run JS like ` node ` /` bun ` ** with the ` esrun ` binary:
37+ ## Run JavaScript
38+
39+ Run JS files like ` node ` /` bun ` :
3740
3841``` sh
39- ./target/release/esrun examples/hello.js
40- ./target/release/esrun examples/crypto.js
41- ./target/release/esrun examples/modules/main.mjs # ES module: import/export + top-level await
42- ./target/release/esrun -e " console.log(6 * 7)"
43- ./target/release/esrun --help
42+ esrun examples/hello.js
43+ esrun examples/modules/main.mjs # ES module: import/export + top-level await
44+ esrun -e " console.log(6 * 7)"
45+ esrun --help
4446```
4547
46- To call it simply as ` esrun file.js ` from anywhere, install it onto your ` PATH ` :
48+ (If you built from source, the binary is at ` ./target/release/esrun ` . To call it
49+ as ` esrun ` from anywhere, run ` cargo install --path crates/runtime-cli ` .)
50+
51+ The full implemented WinterTC surface is available (console, URL, fetch, crypto,
52+ streams, encoding, timers, events); all host capabilities are granted. Inputs run
53+ as ** ES modules** : static ` import ` /` export ` , dynamic ` import() ` , ` import.meta.url ` ,
54+ and native top-level ` await ` all work. Imports resolve as ** local files**
55+ (relative or absolute paths, or ` file: ` URLs) and ** bare specifiers through
56+ ` node_modules ` ** for ES module packages (run ` npm install ` yourself — nothing is
57+ fetched). CommonJS packages and ` node: ` builtins are rejected with a clear
58+ message; import attributes and remote modules are not supported yet.
59+
60+ ## TypeScript
61+
62+ ` esrun ` doesn't execute TypeScript, but it ships editor types for the ` runtime:* `
63+ modules:
4764
4865``` sh
49- cargo install --path crates/runtime-cli # installs `esrun` to ~/.cargo/bin
50- esrun examples/timers.js
66+ esrun types --install # writes the defs into node_modules/@opentf/esrun and wires tsconfig.json
5167```
5268
53- The full implemented WinterTC surface is available (console, URL, fetch, crypto,
54- streams, encoding, timers, events); all host capabilities are granted. Inputs run
55- as ** ES modules** : static ` import ` /` export ` , dynamic ` import() ` ,
56- ` import.meta.url ` , and native top-level ` await ` all work. Imports resolve as
57- ** local files** (relative or absolute paths, or ` file: ` URLs) and ** bare
58- specifiers through ` node_modules ` ** for ES module packages (run ` npm install `
59- yourself — nothing is fetched). CommonJS packages and ` node: ` builtins are
60- rejected with a clear message; import attributes and remote modules are not
61- supported yet.
69+ ` esrun types ` alone prints them to stdout. See
70+ [ esrun.opentechf.org/docs/typescript] ( https://esrun.opentechf.org/docs/typescript ) .
71+
72+ ## Documentation
73+
74+ - ** [ esrun.opentechf.org] ( https://esrun.opentechf.org ) ** — full docs, guides, and
75+ cross-runtime benchmarks.
76+ - ** [ API reference] ( docs/API.md ) ** — globals, scope/non-goals, the ` runtime: `
77+ modules and their exports (canonical).
78+
79+ ## Development
6280
63- ## Common tasks
81+ Build, test, and benchmark from source:
6482
6583| Task | Command |
6684| --- | --- |
67- | Build the ` esrun ` binary | ` cargo build-cli ` |
6885| Build everything (lib + CLI) | ` cargo build-all ` |
69- | Install ` esrun ` on ` PATH ` | ` cargo install --path crates/runtime-cli ` |
70- | Run a JS file | ` esrun <file.js> ` (or ` ./target/release/esrun <file.js> ` ) |
71- | Set up editor TypeScript types | ` esrun types --install ` (writes the ` runtime:* ` defs into ` node_modules/@opentf/esrun ` and wires ` tsconfig.json ` ; ` esrun types ` alone prints them to stdout) |
86+ | Build just the ` esrun ` binary | ` cargo build-cli ` |
7287| Run tests | ` cargo test --workspace ` |
7388| Lints + format check | ` cargo clippy --workspace --all-targets -- -D warnings ` · ` cargo fmt --check ` |
7489| Supply-chain gates | ` cargo deny check ` · ` cargo audit ` |
7590| Startup/throughput microbenchmark | ` cargo run --release -p es-runtime-default-providers --example bench ` |
76- | Cross-runtime benchmark (vs Node/Bun/Deno) | ` bench/run.sh ` (see ` bench/README.md ` ) |
77-
78- ## Documentation
79-
80- - ** [ API reference] ( docs/API.md ) ** — globals, scope/non-goals, the ` runtime: ` modules and their exports (canonical).
81- - ** [ Architecture] ( docs/ARCHITECTURE.md ) ** · ** [ Spec] ( docs/SPEC.md ) ** · ** [ Decisions] ( docs/DECISIONS.md ) ** · ** [ Security review] ( docs/SECURITY-REVIEW.md ) ** · ** [ Licensing] ( docs/LICENSING.md ) **
82- - ** Marketing site** (` @opentf/web ` , in [ ` site/ ` ] ( site/ ) ) — run with ` bun install && bun run dev ` .
83-
84- Every public API is documented in both [ ` docs/API.md ` ] ( docs/API.md ) and the site
85- under ` site/app/docs/** ` , kept in sync (DECISIONS D27).
91+ | Cross-runtime benchmark | ` bench/run.sh ` (see [ ` bench/README.md ` ] ( bench/README.md ) ) |
8692
8793## License
8894
0 commit comments