More Premium Hugo Themes Premium Vue Themes

Vue Compiler

Vue's template compiler reimplemented in Rust!

Vue Compiler

Vue's template compiler reimplemented in Rust!

Github Stars Github Stars: 1110
Last Commit Last Commit: Jan 27, 2024 -
First Commit Created: Jan 15, 2024 -
Vue Compiler screenshot

Overview:

The Vue Compiler in Rust is a project aimed at implementing the Vue compiler in native Go/Rust for improved performance. The project includes a Rust library, CLI binary, and NAPI-based Node.js library. It also offers a wasm-based npm package as a fallback option and a toy for browsers. The project does not support browser builds and removed certain features for size optimization. The project references the official HTML spec for parsing HTML-like files and uses tools like Vue Template Explorer, Nu HTML Checker, and AST Explorer for code generation, error reporting, and inspecting AST nodes.

Features:

  • Native Go/Rust implementation: The project aims to implement the Vue compiler in native Go/Rust, which can help improve performance.
  • Rust library: The project includes a Rust library that can be used for compiling Vue templates.
  • CLI binary: The project provides a command-line interface (CLI) binary that allows users to compile Vue templates.
  • NAPI-based Node.js library: The project includes a Node.js library based on NAPI (Node.js API) for compiling Vue templates.
  • wasm-based npm package: The project offers a WebAssembly (wasm)-based npm package, which can be used as a fallback option if the NAPI library fails to work. It can also be used as a toy for browsers.
  • No browser support: The project does not support browser builds, as most of the features in the full build are additional. However, the template compiler in the browser is already available for toy projects.
  • HTML parsing with official spec: The project references the html spec as the definitive guide for parsing HTML-like files.
  • Vue Template Explorer: The project utilizes the Vue Template Explorer tool, which provides instant results for code generation and error reporting.
  • Nu HTML Checker: The project uses Nu HTML Checker, the official HTML validator from W3C, as the canonical error reporter for HTML parsing.
  • AST Explorer: The project leverages AST Explorer, a tool that allows users to inspect AST nodes interactively.

Installation:

To install the Vue Compiler in Rust, you can follow these steps:

  1. Install Rust:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  1. Clone the project repository:
git clone https://github.com/vuejs/vue-next.git
  1. Navigate to the project directory:
cd vue-next
  1. Build the Rust library:
cargo build
  1. Install the CLI binary:
cargo install --path packages/@vue/compiler-cli
  1. Install the NAPI-based Node.js library:
cd packages/vue/compiler-core
npm install
  1. Install the wasm-based npm package:
npm install @vue/compiler-slim

Summary:

The Vue Compiler in Rust project aims to improve the performance of the Vue compiler by implementing it in native Go/Rust. It provides various libraries and tools for compiling Vue templates, including a Rust library, CLI binary, and NAPI-based Node.js library. The project also offers a wasm-based npm package as a fallback option for browsers. While the project does not support browser builds, it uses the official HTML spec for parsing HTML-like files and utilizes tools like Vue Template Explorer, Nu HTML Checker, and AST Explorer for code generation and error reporting.