Astro's compiler, written in Rust with NAPI-RS bindings for Node.js.
npm install @astrojs/compiler-rs
The Astro compiler transforms .astro component files into JavaScript modules whose default export generates HTML.
import { transform } from "@astrojs/compiler-rs";
const result = transform(source, {
filename: "/Users/astro/Code/project/src/pages/index.astro",
sourcemap: "both",
});The compiler can emit an ESTree-compatible AST using the parse method.
import { parse } from "@astrojs/compiler-rs";
const result = parse(source);
console.log(JSON.stringify(result.ast, null, 2));New contributors welcome! Check out our Contributors Guide for help getting started.
Join us on Discord to meet other maintainers. We'll help you get your first contribution in no time!
Astro is free, open source software made possible by these wonderful sponsors.