Read this first, then use architecture.md for the detailed system map.
CSSX is a monorepo for a CSS-in-JS toolchain. Users write styl, css, or optional pug templates plus styleName and part props. Babel compiles that authoring syntax into style objects and runtime calls. The runtime matches class selectors, applies CSS variables/media queries, supports component parts, and can memoize with teamplay.
- Read
docs/guide/index.md,docs/guide/usage.md, anddocs/guide/component-parts.mdfor the public model. - Read
architecture.mdbefore changing cross-package behavior. - Use the package map below to choose the smallest code area to edit.
packages/cssxjs/: publiccssxjsfacade, CLI, wrappers, package exports.packages/runtime/:process(),matcher(), variables, dimensions, platform helpers, teamplay caching.packages/loaders/: Stylus/CSS loaders and direct compiler wrappers.packages/babel-plugin-rn-stylename-inline/: compiles inlinecssandstyltemplates.packages/babel-plugin-rn-stylename-to-style/: rewrites JSXstyleName,part, old*StyleName, and helper calls.packages/babel-preset-cssxjs/: transform ordering and public Babel options.packages/bundler/: Metro hot-reload path for separate style files.packages/eslint-plugin-cssxjs/: wrapper around React Pug ESLint processor.docs/: user-facing docs; update these when public behavior changes.example/: web demo using Babel plus esbuild.
__CSS_GLOBAL__and__CSS_LOCAL__connect the inline Babel plugin to the JSX/runtime plugin.- Compiled style metadata
__hash__,__vars, and__hasMediaconnects loaders to cached and uncached runtime processing. - Runtime calls have this shape:
runtime(styleName, fileStyles, globalStyles, localStyles, inlineStyleProps). - Style priority is file styles, then global templates, then local templates, then inline props.
- Selector specificity is approximated by class count only.
part='root'maps tostyle; other parts map to{partName}Style.css/styltemplate interpolation is intentionally unsupported.- Cached runtime is selected by
cache: 'teamplay'or by importingobserverfromteamplayorstartupjs.
Install dependencies with the repo package manager:
yarn installRun all package tests:
yarn testRun targeted tests:
cd packages/runtime && yarn test
cd packages/babel-plugin-rn-stylename-inline && yarn test
cd packages/babel-plugin-rn-stylename-to-style && yarn testRun docs locally:
yarn docsRun the example app:
yarn start- For runtime matching changes, update
packages/runtime/test/matcher.mjsandpackages/runtime/test/process.mjs. - For Babel changes, update the relevant Jest snapshots.
- For public API or behavior changes, update
docs/andarchitecture.md. - For Pug, type checking, or ESLint behavior, check whether the implementation lives in
@react-pug/*; this repo often only wraps it. - For separate style files, check both Babel
compileCssImportsbehavior and Metro transformer behavior. - Prefer current source code and
docs/over older package READMEs when they conflict.