@griffel/transform
v1.1.0
Published
A package that performs build time transforms for Griffel
Keywords
Readme
@griffel/transform
A high-performance transformation package for Griffel that unifies CSS-in-JS transformation and extraction functionality.
Overview
@griffel/transform provides a unified approach to CSS-in-JS transformation and extraction for Griffel. It replaces Babel-based processing with modern OXC-based parsing for improved performance while maintaining full compatibility with existing Griffel APIs.
Install
yarn add --dev @griffel/transform
# or
npm install --save-dev @griffel/transformUsage
Basic Transformation
import { transformSync } from '@griffel/transform';
const sourceCode = `
import { makeStyles } from '@griffel/react';
const useStyles = makeStyles({
root: { color: 'red' }
});
`;
const result = transformSync(sourceCode, {
filename: 'styles.ts',
});
console.log(result.code); // Transformed code with __css calls
console.log(result.cssRulesByBucket); // Extracted CSS rulesAPI Reference
transformSync(sourceCode, options)
Transforms source code containing makeStyles or makeResetStyles calls.
Parameters:
sourceCode(string): Source code to transformoptions(TransformOptions): Transformation options
Returns: TransformResult object containing:
code: Transformed source codecssRulesByBucket: Extracted CSS rules organized by bucket typeusedProcessing: Whether any transformations were appliedusedVMForEvaluation: Whether VM evaluation was used
TransformOptions:
filename(string): File path for error reporting and source mapsclassNameHashSalt?(string): Salt for CSS class name generationgenerateMetadata?(boolean): Include metadata in CSS rulesmodules?(string[]): Module sources to processbabelOptions?(object): Babel configuration for complex evaluationsevaluationRules?(array): Rules for determining evaluation strategy
