# moss **Repository Path**: pauljoihn21/moss ## Basic Information - **Project Name**: moss - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-08-08 - **Last Updated**: 2026-08-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # moss A Sass/SCSS compiler written in Rust. > **moss** — *Moss is Our Sass, in Rust* ## Features - Full SCSS parsing (hand-written recursive descent parser) - SassScript evaluation with all value types (numbers, strings, colors, lists, maps, booleans, null) - 17 CSS color spaces with conversion matrices and gamut mapping (sRGB, Display P3, A98, ProPhoto, Rec2020, HSL, HWB, Lab, LCH, OKLab, OKLCH, XYZ-D65, XYZ-D50, LMS) - Built-in functions: `sass:math`, `sass:string`, `sass:list`, `sass:map`, `sass:color`, `sass:meta`, `sass:selector` - Module system (`@use`, `@forward`, `@import`) - `@extend` with extension store and transitive resolution - Control flow: `@if`, `@each`, `@for`, `@while` - Mixins and functions with `@content` - CSS serialization (expanded and compressed output) - Source map generation (v3 format) - Watch mode with file dependency tracking - WASM bindings for browser/Node.js usage - sass-spec integration test runner ## Quick Start ```sh # Build cargo build --release # Compile a file cargo run --release -- -i input.scss -o output.css # Watch mode cargo run --release -- -i input.scss --watch # Compressed output cargo run --release -- -i input.scss -o output.css --style compressed ``` ## As a Library ```rust use moss_core::eval; use moss_core::span::SourceId; let css = eval::compile_string("a { color: red; }", SourceId(0))?; println!("{}", css); // Output: a { // color: red; // } ``` ## WASM Usage ```sh # Build WASM for web wasm-pack build --target web # Build WASM for Node.js wasm-pack build --target nodejs ``` ```js import { Compiler } from "moss"; const compiler = new Compiler(); const result = compiler.compileString("$color: #f00; a { color: $color; }"); console.log(result.css); // Output: a { // color: #f00; // } ``` ### Custom Importers ```js import { Compiler, WasmImporter } from "moss"; const importer = new WasmImporter({ canonicalize(url) { return new URL(url, baseUrl).href; }, load(url) { return { contents: fs.readFileSync(url, 'utf8') }; } }); const result = compiler.compileString("@use 'vars';", { importer }); ``` ## Architecture ``` moss/ ├── crates/ │ ├── moss-core/ # Core compiler library │ │ ├── ast/ # AST types (statements, expressions, selectors, CSS) │ │ ├── parse/ # Hand-written recursive descent parsers │ │ ├── eval/ # Evaluator (Sass AST → CSS AST) │ │ ├── serialize/ # CSS serializer (CSS AST → String) │ │ ├── value/ # SassScript value types │ │ │ ├── color.rs # SassColor, ColorSpace (17 spaces) │ │ │ └── color_conversions.rs # 46 conversion matrices │ │ └── extend/ # @extend implementation │ ├── moss-cli/ # CLI tool (clap) │ ├── moss-wasm/ # WASM bindings (wasm_bindgen) │ └── moss-spec-runner/ # sass-spec integration test runner └── openspec/ # OpenSpec change tracking ``` ## sass-spec Compliance moss is tested against the [sass-spec](https://github.com/sass/sass-spec) test suite: ```sh cargo test --test sass_spec ``` Current pass rate: ~63% (1469/2316 tests across 8 suites). ## Development ```sh # Run all tests cargo test # Run clippy cargo clippy -- -D warnings # Format code cargo fmt # Run sass-spec cargo test --test sass_spec ``` ## License MIT