All-in-One Vue compiler written in Rust
See the code
All-In-One Vue compiler written in Rust. Currently in alpha stage, the closest goal is to reach feature-parity with the current Vue SFC compiler.
Instructions on how to use fervid in Vue CLI and Vite are coming very soon!
Fervid includes an experimental Language Server (fervid_lsp) with fast Nuxt-oriented completion and go-to-definition. See crates/fervid_lsp/README.md for installation and setup.
A minimal target of this project includes (see Roadmap):
<script setup> support;This project uses Vue SFC playground as its reference to compare the output. As of November 2023, fervid is capable of producing the DEV and PROD code almost identical to the official compiler, with some differences in:
{{ foo + bar.buzz }} or <div v-if="isShown">.
Support for them in fervid is almost complete.To check correctness of fervid, you can compare the playground output to the output of official compiler.
Please note that "correctness" of output will depend on the version of Vue, as Vue team may change the output and/or behaviour of the compiler. This is a challenge for fervid.
Yes, it is incredibly fast. In fact, below is a benchmark run for a test component.
@vue/compiler-sfc:
954 ops/s, ±1.15% | slowest, 98.42% slower
@fervid/napi sync:
6 464 ops/s, ±0.08% | 89.29% slower
@fervid/napi async (4 threads):
11 624 ops/s, ±2.12% | 80.73% slower
@fervid/napi async CPUS (23 threads):
60 329 ops/s, ±0.67% | fastest
Note: results are for AMD Ryzen 9 7900X running on Fedora 38 with kernel version 6.5.9
Benchmarking in Node.js has been done using benny, slightly modified to take libuv threads into consideration.
Source code for a benchmark.
Better benchmarking is a TODO and has a lower priority compared to feature-completeness and usability in real-world scenarios, so Pull Requests are welcome.
fervid The main crate. It exports a compile method which glues all the stages together, from taking a source string to outputting compiled code and assets.
For finer-grained compilation you can use other crates directly.
fervid_core The core structures and functionality shared across crates.
fervid_parser Parser for Vue SFC based on swc_html_parser.
fervid_transform This crate is responsible for AST transformation.
Handles <script> and <script setup> analysis and transformations, along with Typescript.
Based on SWC and provides fast and correct transforms without using regular expressions.
fervid_css Works on the <style> block and enables scoped styles, CSS Modules and Vue-specific transformations. The backbone of this crate is swc_css_parser.
fervid_napi NAPI-rs bindings for usage in Node.js.
fervid_deno Deno bindings for usage in Deno.
fervid_plugin and fervid_plugin_api These crates allow authoring plugins for fervid in Rust using dynamically loaded libraries (.so, .dll and .dylib).
These plugins allow anyone to customize how a Vue SFC is parsed, optimized and code-generated.
This project uses just as a task runner to simplify building, testing, and developing across all crates.
To get started:
Any contributions are welcome!
Parser
Transformer
setup/data/props analysis<style scoped><script setup> support
Code generator
Basic Vue3 code generation
createElementVNodestyle mergingclass mergingcreateVNode_ctx, $data, $setup)DEV/PROD mode
Hot Module Replacement (HMR)
Vue 2.7 support
SSR with inline critical CSS support
Eager pre-compilation of Vue imports (avoid unneccessary bundler->compiler calls)
Integrations
Rust
86.3%
TypeScript
8.8%
JavaScript
3.2%
Vue
1.3%
All-in-One Vue compiler written in Rust
See the code
All-In-One Vue compiler written in Rust. Currently in alpha stage, the closest goal is to reach feature-parity with the current Vue SFC compiler.
Instructions on how to use fervid in Vue CLI and Vite are coming very soon!
Fervid includes an experimental Language Server (fervid_lsp) with fast Nuxt-oriented completion and go-to-definition. See crates/fervid_lsp/README.md for installation and setup.
A minimal target of this project includes (see Roadmap):
<script setup> support;This project uses Vue SFC playground as its reference to compare the output. As of November 2023, fervid is capable of producing the DEV and PROD code almost identical to the official compiler, with some differences in:
{{ foo + bar.buzz }} or <div v-if="isShown">.
Support for them in fervid is almost complete.To check correctness of fervid, you can compare the playground output to the output of official compiler.
Please note that "correctness" of output will depend on the version of Vue, as Vue team may change the output and/or behaviour of the compiler. This is a challenge for fervid.
Yes, it is incredibly fast. In fact, below is a benchmark run for a test component.
@vue/compiler-sfc:
954 ops/s, ±1.15% | slowest, 98.42% slower
@fervid/napi sync:
6 464 ops/s, ±0.08% | 89.29% slower
@fervid/napi async (4 threads):
11 624 ops/s, ±2.12% | 80.73% slower
@fervid/napi async CPUS (23 threads):
60 329 ops/s, ±0.67% | fastest
Note: results are for AMD Ryzen 9 7900X running on Fedora 38 with kernel version 6.5.9
Benchmarking in Node.js has been done using benny, slightly modified to take libuv threads into consideration.
Source code for a benchmark.
Better benchmarking is a TODO and has a lower priority compared to feature-completeness and usability in real-world scenarios, so Pull Requests are welcome.
fervid The main crate. It exports a compile method which glues all the stages together, from taking a source string to outputting compiled code and assets.
For finer-grained compilation you can use other crates directly.
fervid_core The core structures and functionality shared across crates.
fervid_parser Parser for Vue SFC based on swc_html_parser.
fervid_transform This crate is responsible for AST transformation.
Handles <script> and <script setup> analysis and transformations, along with Typescript.
Based on SWC and provides fast and correct transforms without using regular expressions.
fervid_css Works on the <style> block and enables scoped styles, CSS Modules and Vue-specific transformations. The backbone of this crate is swc_css_parser.
fervid_napi NAPI-rs bindings for usage in Node.js.
fervid_deno Deno bindings for usage in Deno.
fervid_plugin and fervid_plugin_api These crates allow authoring plugins for fervid in Rust using dynamically loaded libraries (.so, .dll and .dylib).
These plugins allow anyone to customize how a Vue SFC is parsed, optimized and code-generated.
This project uses just as a task runner to simplify building, testing, and developing across all crates.
To get started:
Any contributions are welcome!
Parser
Transformer
setup/data/props analysis<style scoped><script setup> support
Code generator
Basic Vue3 code generation
createElementVNodestyle mergingclass mergingcreateVNode_ctx, $data, $setup)DEV/PROD mode
Hot Module Replacement (HMR)
Vue 2.7 support
SSR with inline critical CSS support
Eager pre-compilation of Vue imports (avoid unneccessary bundler->compiler calls)
Integrations
Rust
86.3%
TypeScript
8.8%
JavaScript
3.2%
Vue
1.3%