Compile the Vue template compiler (@vue/compiler-dom) to native code using Static Hermes, making it callable from Rust without a JavaScript runtime.
- pnpm - Node.js package manager
- just - Command runner
- Ninja - Build system (for compiling Hermes)
- CMake - Build configuration
- Rust - For building the Rust library
# macOS
brew install just
# Linux
cargo install just
# Windows (via cargo)
cargo install just# Clone the repository
git clone <repo-url>
cd libvue_compiler_sfc
# Set up everything (install deps, build Hermes)
just setup
# Build the Rust library
just build
# Run the demo
just runRun just to see all available commands:
| Command | Description |
|---|---|
just setup |
Install dependencies, init submodules, build Hermes |
just build |
Build the Rust project (release mode) |
just run |
Run the demo binary |
just bench |
Run all benchmarks |
just bench-native |
Run Static Hermes benchmark |
just bench-node |
Run Node.js V8 benchmark |
just clean |
Clean build artifacts |
- Bundle: Vue compiler is bundled into a single JS file using Rolldown
- Compile: Static Hermes compiles the JS to native code (
.ofile) - Link: Rust links against the compiled object and Hermes runtime
- Call: Rust code can call
compile_template()directly
See CLAUDE.md for detailed architecture documentation.
use libvue_compiler_sfc::Compiler;
fn main() {
let compiler = Compiler::new().expect("Failed to create compiler");
// compile_template(source, filename, scope_id, is_scoped, script_bindings)
let result = compiler
.compile_template("<div>{{ msg }}</div>", "App.vue", "scope-id", false, None)
.unwrap();
println!("{}", result.code());
}Compare native compilation vs Node.js V8:
just benchISC