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.
- β‘ Blazing Fast: Significantly faster build times by leveraging NAPI-RS/SWC instead of Babel
- π§ Performance-First Alternative: Built from the ground up in Rust for maximum speed and efficiency
- π§© Modular Architecture: 17 atomic Rust crates with strict dependency layering for maximum parallel compilation and surgical rebuilds
- π¦ Complete Ecosystem: Community-built toolkit covering compilation to CSS parsing
- π Universal Integration: Works seamlessly with Next.js, Webpack, Vite, Rollup, and more
- π‘οΈ Type Safe: Full Rust implementation with comprehensive error handling
- π€ Community Driven: Open source with active community contributions and support
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 17 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-compiledlazy_static!regex patterns for CSS value matchingstylex-utilsβ Lightweight SWC AST helpers
stylex-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 partialpackage.jsonexports support
stylex-structuresβ 15 foundational struct modules:StylexOptions,UidGenerator,PluginPass,NamedImportSource,Order, and more
stylex-typesβ Cross-coupled core types (InjectableStyle*,MetaData) and theStyleOptionstrait
stylex-astβ SWC AST factory and convertor functions (semantically namedcreate_*,convert_*)
stylex-evaluatorβ Pure JS expression evaluator; no transform side effects
stylex-cssβ Unified CSS processing: generation (LTR/RTL), whitespace normalization, value parsing, property ordering strategies, and pseudo-class selector utilities
stylex-transformβ Main SWC transform:StyleXTransform,StateManager, SWCFoldvisitor, and all injection logic
stylex-rs-compilerβ NAPI-RS compiler exposing the full pipeline to Node.js
graph TD
subgraph L0["Primitives"]
stylex_constants["constants"]
stylex_regex["regex"]
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_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_transform --> stylex_ast
stylex_transform --> stylex_constants
stylex_transform --> stylex_css
stylex_transform --> stylex_css_parser
stylex_transform --> stylex_enums
stylex_transform --> stylex_logs
stylex_transform --> stylex_macros
stylex_transform --> stylex_path_resolver
stylex_transform --> stylex_regex
stylex_transform --> stylex_structures
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_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 pipelines
test-parserβ Jest test parser for maintaining compatibility with official StyleXdesign-systemβ Internal design system for consistent workspace examples
eslint-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 testThis 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-checkThe 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 tools
Build 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 artifacts
Development Commands:
make devβ Start development serversmake watchβ Watch for changes and rebuild
Quality Commands:
make lintβ Run linting on all packagesmake formatβ Format all codemake typecheckβ Run TypeScript type checkingmake quick-checkβ Quick development check (format, lint, typecheck)make full-checkβ Full development check including tests
Test Commands:
make testβ Run all testsmake test-visualβ Run visual regression testsmake benchβ Run benchmarks
App Commands:
make apps-buildβ Build all example appsmake apps-devβ Start development servers for all appsmake apps-cleanβ Clean all app build artifactsmake app-nextjs-devβ Start Next.js example app in development modemake app-nextjs-buildβ Build Next.js example appmake app-nextjs-serveβ Serve Next.js example app (requires build first)make app-vite-devβ Start Vite example app in development modemake app-vite-buildβ Build Vite example appmake app-vite-serveβ Serve Vite example app (requires build first)make app-webpack-devβ Start Webpack example app in development modemake app-webpack-buildβ Build Webpack example appmake app-rollup-devβ Start Rollup example app in development modemake app-rollup-buildβ Build Rollup example appmake apps-serve-commonβ Serve commonly used example apps simultaneously
Documentation & Release:
make docsβ Generate documentationmake infoβ Show project information
Package Commands:
Bulk Package Operations:
make packages-buildβ Build all Node.js packagesmake packages-lintβ Lint all Node.js packagesmake packages-testβ Test all Node.js packagesmake packages-typecheckβ Typecheck all Node.js packagesmake packages-cleanβ Clean all Node.js packages
Bulk Rust Crate Operations:
make crates-buildβ Build all Rust cratesmake crates-formatβ Format all Rust cratesmake crates-lintβ Lint all Rust cratesmake crates-cleanβ Clean all Rust cratesmake crates-docsβ Generate docs for all Rust crates
Individual Package Commands:
Each package has individual commands available in the format
pkg-{name}-{action} and crate-{name}-{action}:
- Node.js packages: unplugin, nextjs, webpack, rollup, postcss, jest, design, playwright, eslint, typescript
- Rust crates: compiler, transform, resolver, parser, and all atomic crates (constants, regex, utils, macros, enums, js, logs, css-parser, structures, types, ast, evaluator, css, etc.)
- Available actions: build, lint, test, typecheck, clean (for Node.js) / build, format, lint, clean, docs (for Rust)
Examples:
make pkg-unplugin-buildβ Build unplugin packagemake pkg-webpack-lintβ Lint webpack plugin packagemake crate-compiler-formatβ Format Rust compiler cratemake crate-transform-docsβ Generate docs for transform cratemake crate-ast-lintβ Lint the AST utilities crate
If you prefer to use the tools directly:
# Install dependencies
pnpm install
# Build all packages
pnpm build
# Run tests
pnpm test
# Run visual regression tests
pnpm test:visual
# Lint code
pnpm lint
# Check lint
pnpm lint:check
# Format code
pnpm format
# Check format
pnpm format:check
# Typecheck code
pnpm typecheckContributions are welcome! Please read our contributing guidelines and submit pull requests to the develop branch.
MIT Licensed. See LICENSE for details.