Community-driven, high-performance StyleX compiler and tooling ecosystem built with Rust
[!IMPORTANT] This is a community-written implementation of StyleX tooling. Built with love by the open source community, it aims to provide a high-performance alternative to the official StyleX tooling while not being affiliated with or officially supported by Meta/Facebook.
A comprehensive monorepo providing a community-built
napi-rs compiler, SWC plugin, and
complete CSS parser for StyleX. Built from
the ground up in Rust for maximum performance and developer experience.
Perfect for developers who want blazing-fast StyleX compilation and are excited about Rust-powered tooling!
# For Next.js projects
npm install --save-dev @stylexswc/nextjs-plugin
# For other build tools
npm install --save-dev @stylexswc/unplugin
// next.config.js
const stylexPlugin = require('@stylexswc/nextjs-plugin');
module.exports = stylexPlugin({
rsOptions: {
dev: process.env.NODE_ENV !== 'production',
},
})();
// next.config.ts
import stylexPlugin from '@stylexswc/nextjs-plugin/turbopack';
export default stylexPlugin({
rsOptions: {
dev: process.env.NODE_ENV !== 'production',
},
})();
This monorepo is organized into a layered, strictly-scoped crate graph designed for maximum parallel compilation and clear domain boundaries. Each Rust crate owns exactly one concern — no re-export facades, no mixed-domain files.
The compiler pipeline is built from 18 atomic Rust crates arranged in a strict dependency DAG. Higher layers depend only on lower layers — never the reverse.
stylex-constants — Static lookup tables,
keyword sets, and compile-time constantsstylex-regex — Pre-compiled lazy_static!
regex patterns for CSS value matchingstylex-styleq — Rust port of the runtime
styleq class-name mergerstylex-utils — Lightweight SWC AST helpersstylex-macros — Error-handling and diagnostic
macros (stylex_panic!, stylex_bail!, stylex_unwrap!, etc.)stylex-enums — 14 enum modules: CSSSyntax,
ValueWithDefault, ImportPathResolution, StyleVarsToKeep, and morestylex-js — JS runtime guard helpers
(is_valid_callee, is_mutation_expr, is_invalid_method)stylex-logs — Structured logging with
ANSI-colored [StyleX]-branded output for the NAPI-RS pipelinestylex-css-parser — High-performance CSS
value parser with comprehensive type, property, and at-rule coveragestylex-path-resolver — Import path
resolution with partial package.json exports supportstylex-structures — 15 foundational struct
modules: StylexOptions, UidGenerator, PluginPass, NamedImportSource,
Order, and morestylex-types — Cross-coupled core types
(InjectableStyle*, MetaData) and the StyleOptions traitstylex-ast — SWC AST factory and convertor
functions (semantically named create_*, convert_*)stylex-evaluator — Pure JS expression
evaluator; no transform side effectsstylex-css — Unified CSS processing: generation
(LTR/RTL), whitespace normalization, value parsing, property ordering
strategies, and pseudo-class selector utilitiesstylex-transform — Main SWC transform:
StyleXTransform, StateManager, SWC Fold visitor, and all injection logicstylex-rs-compiler — NAPI-RS compiler
exposing the full pipeline to Node.jsgraph TD
subgraph L0["Primitives"]
stylex_constants["constants"]
stylex_regex["regex"]
stylex_styleq["styleq"]
stylex_utils["utils"]
end
subgraph L1["Proc Macros"]
stylex_macros["macros"]
end
subgraph L2["Domain Leaves"]
stylex_enums["enums"]
stylex_js["js"]
stylex_logs["logs"]
stylex_css_parser["css-parser"]
stylex_path_resolver["path-resolver"]
end
subgraph L3["Core Data Structures"]
stylex_structures["structures"]
end
subgraph L4["Type System"]
stylex_types["types"]
end
subgraph L5["AST Foundations"]
stylex_ast["ast"]
end
subgraph L6["Evaluation"]
stylex_evaluator["evaluator"]
end
subgraph L7["CSS Processing"]
stylex_css["css"]
end
subgraph L8["StyleX Transform"]
stylex_transform["transform"]
end
subgraph L9["Compilers"]
stylex_compiler_rs["rs-compiler"]
end
stylex_utils --> stylex_regex
stylex_macros --> stylex_constants
stylex_enums --> stylex_macros
stylex_js --> stylex_constants
stylex_js --> stylex_macros
stylex_logs --> stylex_macros
stylex_css_parser --> stylex_macros
stylex_path_resolver --> stylex_macros
stylex_structures --> stylex_constants
stylex_structures --> stylex_enums
stylex_structures --> stylex_macros
stylex_types --> stylex_constants
stylex_types --> stylex_enums
stylex_types --> stylex_macros
stylex_types --> stylex_structures
stylex_types --> stylex_utils
stylex_ast --> stylex_constants
stylex_ast --> stylex_macros
stylex_ast --> stylex_types
stylex_ast --> stylex_utils
stylex_evaluator --> stylex_ast
stylex_evaluator --> stylex_constants
stylex_evaluator --> stylex_js
stylex_evaluator --> stylex_macros
stylex_evaluator --> stylex_path_resolver
stylex_evaluator --> stylex_types
stylex_css --> stylex_ast
stylex_css --> stylex_constants
stylex_css --> stylex_css_parser
stylex_css --> stylex_enums
stylex_css --> stylex_evaluator
stylex_css --> stylex_macros
stylex_css --> stylex_regex
stylex_css --> stylex_structures
stylex_css --> stylex_types
stylex_css --> stylex_utils
stylex_transform --> stylex_ast
stylex_transform --> stylex_constants
stylex_transform --> stylex_css
stylex_transform --> stylex_css_parser
stylex_transform --> stylex_enums
stylex_transform --> stylex_evaluator
stylex_transform --> stylex_logs
stylex_transform --> stylex_macros
stylex_transform --> stylex_path_resolver
stylex_transform --> stylex_regex
stylex_transform --> stylex_structures
stylex_transform --> stylex_styleq
stylex_transform --> stylex_types
stylex_transform --> stylex_utils
stylex_compiler_rs --> stylex_ast
stylex_compiler_rs --> stylex_enums
stylex_compiler_rs --> stylex_logs
stylex_compiler_rs --> stylex_macros
stylex_compiler_rs --> stylex_regex
stylex_compiler_rs --> stylex_structures
stylex_compiler_rs --> stylex_transform
stylex_compiler_rs --> stylex_types
stylex_compiler_rs --> stylex_utils
classDef l0 fill:#e8e8e8,stroke:#999,color:#333
classDef l1 fill:#dce8ff,stroke:#6699cc,color:#333
classDef l2 fill:#dcf5dc,stroke:#66aa66,color:#333
classDef l3 fill:#fff3dc,stroke:#cc9933,color:#333
classDef l4 fill:#ffe8dc,stroke:#cc6633,color:#333
classDef l5 fill:#f5dcff,stroke:#9933cc,color:#333
classDef l6 fill:#dcfff5,stroke:#33aaaa,color:#333
classDef l7 fill:#ffdcdc,stroke:#cc3333,color:#333
classDef l8 fill:#fffdc0,stroke:#aaaa33,color:#333
classDef l9 fill:#ffc0c0,stroke:#cc0000,color:#333
class stylex_constants,stylex_regex,stylex_styleq,stylex_utils l0
class stylex_macros l1
class stylex_enums,stylex_js,stylex_logs,stylex_css_parser,stylex_path_resolver l2
class stylex_structures l3
class stylex_types l4
class stylex_ast l5
class stylex_evaluator l6
class stylex_css l7
class stylex_transform l8
class stylex_compiler_rs l9
nextjs-plugin — Next.js configuration
wrapper with seamless SWC integrationturbopack-plugin — Turbopack loader for
Next.js with high-performance StyleX compilationunplugin — Universal plugin supporting Vite,
Webpack, Rollup, Rspack, and 8+ build toolsjest — Jest transformer for StyleX testing workflowspostcss-plugin — PostCSS integration for
existing CSS pipelinestest-parser — Jest test parser for
maintaining compatibility with official StyleXdesign-system — Internal design system for
consistent workspace exampleseslint-config — Shared ESLint configurationtypescript-config — TypeScript
configuration presetsplaywright — Visual regression testing setup| Tool | Package | Experience |
|---|---|---|
| Next.js (Webpack) | @stylexswc/nextjs-plugin |
🚀 Native SWC Integration |
| Next.js (Turbopack) | @stylexswc/nextjs-plugin/turbopack |
⚡ Ultra-Fast Builds |
| Vite | @stylexswc/unplugin |
⚡ Lightning Fast HMR |
| Webpack | @stylexswc/unplugin |
🔧 Seamless Integration |
| Rollup | @stylexswc/unplugin |
📦 Optimized Bundling |
| Jest | @stylexswc/jest |
🧪 Reliable Testing |
| PostCSS | @stylexswc/postcss-plugin |
🎨 CSS Pipeline Ready |
| Rspack | @stylexswc/unplugin |
🚀 Rust-Powered Speed |
| Farm, Rsbuild, Solid | @stylexswc/unplugin |
🌟 Modern Build Experience |
# Clone the repository
git clone https://github.com/Dwlad90/stylex-swc-plugin.git
# Install dependencies
pnpm install
# Build all packages
pnpm build
# Run tests
pnpm test
This project includes a comprehensive Makefile that provides convenient shortcuts for common development tasks. The Makefile integrates with both the Node.js ecosystem (using pnpm and Turborepo) and Rust toolchain.
# Setup development environment
make setup
# Show all available commands
make help
# Build all packages
make build
# Start development servers
make dev
# Run tests
make test
# Run quality checks
make quick-check
The Makefile organizes commands into several categories:
Setup Commands:
make install — Install all dependencies (Node.js and Rust)make setup — Full development environment setupmake prepare — Prepare hooks and development toolsBuild Commands:
make build — Build all packages (Node.js and Rust)make build-rust — Build only Rust packagesmake build-node — Build only Node.js packagesmake clean — Clean all build artifactsDevelopment Commands:
make dev — Start development serversmake watch — Watch for changes a$ claude mcp add stylex-swc-plugin \
-- python -m otcore.mcp_server <graph>