Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

withastro/compiler-rs

Open more actions menu

Repository files navigation

Astro Compiler

Astro's compiler, written in Rust with NAPI-RS bindings for Node.js.

Install

npm install @astrojs/compiler-rs

Usage

Transform .astro to JavaScript

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",
});

Parse .astro and return an AST

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));

Contributing

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!

Links

Sponsors

Astro is free, open source software made possible by these wonderful sponsors.

❤️ Sponsor Astro! ❤️

Sponsor logos including the current Astro Sponsors, Gold Sponsors, and Exclusive Partner Sponsors: Netlify, Sentry, and Project IDX.

About

The Astro compiler

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.