Skip to main content

verter_core/
lib.rs

1//! # verter_core — Vue SFC compiler
2//!
3//! Core Rust crate for the Verter Vue compiler. Handles the full compilation
4//! pipeline from Vue Single File Components (SFCs) to compiled output:
5//!
6//! ```text
7//! Vue SFC source
8//!     ↓ tokenizer   — byte-level SFC tokenization
9//!     ↓ parser      — builds arena-based template AST + extracts script/style blocks
10//!     ↓ script      — macro processing, binding extraction, component wrapper
11//!     ↓ template    — render function codegen (VDOM or Vapor backends)
12//!     ↓ style/css   — scoped CSS, CSS Modules, v-bind() replacement
13//!     ↓ compile     — orchestrates the above, applies CodeTransform, emits output
14//! ```
15//!
16//! ## Crate boundaries
17//!
18//! - **Rust** (this crate): tokenization → parsing → AST → template/script/style codegen
19//! - **TypeScript** (`@verter/core`): SFC-to-TSX transformation for IDE type checking
20//! - **NAPI** (`verter_napi`): bridges this crate to Node.js for build-time use (unplugin)
21//! - **WASM** (`verter_wasm`): bridges this crate to the browser for the playground
22//!
23//! ## Visibility
24//!
25//! Modules used only by `verter_bench` (`ast`, `code_transform`, `script`,
26//! `style`, `template`) are feature-gated behind the `bench` feature.
27//! They are `pub(crate)` by default and become `pub` when
28//! `features = ["bench"]` is enabled.
29
30// Shared infrastructure
31#[cfg(feature = "bench")]
32pub mod code_transform;
33#[cfg(not(feature = "bench"))]
34pub(crate) mod code_transform;
35
36pub mod common;
37pub mod css;
38pub mod cursor;
39pub mod strip_types;
40pub mod tokenizer;
41pub mod utils;
42
43// Diagnostic infrastructure
44pub mod diagnostics;
45
46// Core compilation modules
47#[cfg(feature = "bench")]
48pub mod ast;
49#[cfg(not(feature = "bench"))]
50pub(crate) mod ast;
51
52pub mod compile;
53pub mod parser;
54
55#[cfg(feature = "bench")]
56pub mod script;
57#[cfg(not(feature = "bench"))]
58pub(crate) mod script;
59
60#[cfg(feature = "bench")]
61pub mod style;
62#[cfg(not(feature = "bench"))]
63pub(crate) mod style;
64
65#[cfg(feature = "bench")]
66pub mod template;
67#[cfg(not(feature = "bench"))]
68pub(crate) mod template;
69
70// IDE code generation (TSX for TS projects, JSX+JSDoc for JS projects)
71pub(crate) mod ide;
72
73// TSC code generation (vue-tsc replacement)
74pub mod tsc;
75
76// Re-export the @verter/types declarations for the LSP and verter-tsc
77pub use ide::script::VERTER_TYPES_AMBIENT_MODULE;
78pub use ide::script::VERTER_TYPES_STANDALONE_DTS;
79
80pub mod types;
81
82#[cfg(test)]
83mod compile_ported_tests;
84#[cfg(test)]
85mod sourcemap_e2e_tests;
86#[cfg(test)]
87pub(crate) mod test_helpers;
88#[cfg(test)]
89mod v5_process_ported_tests;