Lightweight Rust example that embeds a JavaScript runtime using deno_core.
This repository contains a minimal Rust program that loads and runs JavaScript files from src/ using the Deno core crate. It demonstrates how to host and execute JS from Rust with an embedded runtime.
Requirements:
- Rust toolchain with
cargo(stable channel)
Files:
src/main.rs: Rust entry point that boots the JS runtime.src/runtime.js: Runtime helper code used by the Rust host.src/example.js: Example JavaScript file demonstrating usage.
Build & Run
Build (debug):
cargo buildRun the program:
cargo runFor an optimized build:
cargo build --release
./target/release/runjs-testNote: cargo run automatically builds and runs the binary.
How to use
- Edit or add JavaScript files in
src/(for example,src/example.js). - The Rust host (
src/main.rs) will load/execute or import these scripts via the embeddeddeno_coreruntime.
Development tips
- Make small changes to
src/example.jsand re-runcargo runto iterate quickly. - Use
cargo build --releasewhen benchmarking or preparing a distribution.