Skip to content

Commit

Permalink
feat: add v-pre implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenix-ru committed Nov 20, 2023
1 parent 0bc9f82 commit b2cf104
Show file tree
Hide file tree
Showing 10 changed files with 870 additions and 703 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Code generator
- [x] v-html
- [ ] v-memo
- [ ] v-once
- [ ] v-pre
- [x] v-pre
- [x] v-text
- [x] Custom directives
- [x] Built-in components
Expand Down
3 changes: 2 additions & 1 deletion crates/fervid/benches/codegen_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ fn codegen_benchmark(c: &mut Criterion) {
for (name, component) in FIXTURES {
c.bench_with_input(BenchmarkId::new("codegen: generate CSR+DEV", name), &component, |b, component| {
let mut errors = Vec::new();
let res = fervid_parser::parse_sfc(component, &mut errors);
let mut parser = fervid_parser::SfcParser::new(&component, &mut errors);
let res = parser.parse_sfc();
let sfc_blocks = res.unwrap();
let mut template_block = sfc_blocks.template;
let Some(ref mut template_block) = template_block else {
Expand Down
3 changes: 2 additions & 1 deletion crates/fervid/benches/parser_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ fn parser_benchmark(c: &mut Criterion) {
|b, component| {
let mut errors = Vec::new();
b.iter(|| {
let _ = fervid_parser::parse_sfc(black_box(component), &mut errors);
let mut parser = fervid_parser::SfcParser::new(black_box(&component), &mut errors);
let _ = parser.parse_sfc();
errors.clear();
})
},
Expand Down
3 changes: 2 additions & 1 deletion crates/fervid/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ pub fn compile_sync_naive(source: &str, is_prod: bool) -> Result<String, String>
// })?;

let mut errors = Vec::new();
let sfc = fervid_parser::parse_sfc(&source, &mut errors).map_err(|err| {
let mut parser = fervid_parser::SfcParser::new(source, &mut errors);
let sfc = parser.parse_sfc().map_err(|err| {
return err.to_string();
})?;

Expand Down
Loading

0 comments on commit b2cf104

Please sign in to comment.