This Rust library is designed for parsing Vue Single-File Components (SFCs), generating Abstract Syntax Trees (ASTs), modifying those ASTs, and generating new Vue SFC files.
Note: This library is not a compiler and does not generate runtime objects for Vue SFCs. It is intended for batch modification of Vue SFC source code files.
- Parse Vue SFCs: Efficiently parse Vue SFC files to generate ASTs.
- Modify ASTs: Make modifications to the ASTs, allowing for programmatic changes to the Vue component structure.
- Generate Vue SFCs: Create new Vue SFC files from modified ASTs.
Add this library to your Cargo.toml
file:
[dependencies]
vue-sfc = "0.1.0"
Then, in your Rust code, you can import and use the library:
use vue_sfc_rs::{parse_sfc, generate_sfc, modify_ast};
- Parsing a Vue SFC File:
let sfc = parse_sfc("path/to/your/vue.sfc");
- Modifying the AST:
let modified_ast = modify_ast(&sfc.ast, |ast| {
// Your modification logic here
});
- Generating a new Vue SFC File:
generate_sfc("path/to/output/vue.sfc", &modified_ast);
Contributions are welcome! Please feel free to submit issues, pull requests, or feature requests.