@griffel/transform 2.0.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,12 +1,25 @@
1
1
  # Change Log - @griffel/transform
2
2
 
3
- This log was last generated on Fri, 13 Mar 2026 16:59:28 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 23 Mar 2026 16:49:14 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 3.0.0
8
+
9
+ Mon, 23 Mar 2026 16:49:14 GMT
10
+
11
+ ### Major changes
12
+
13
+ - BREAKING: rename modules to importsToTransform, add functionsToTransform option (olfedias@microsoft.com)
14
+
15
+ ### Patches
16
+
17
+ - fix: reverse styleCalls iteration to match CSS rule ordering of old plugin (olfedias@microsoft.com)
18
+ - fix: add zIndex fallback values in fluentTokensPlugin (olfedias@microsoft.com)
19
+
7
20
  ## 2.0.2
8
21
 
9
- Fri, 13 Mar 2026 16:59:28 GMT
22
+ Fri, 13 Mar 2026 17:00:44 GMT
10
23
 
11
24
  ### Patches
12
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@griffel/transform",
3
- "version": "2.0.2",
3
+ "version": "3.0.0",
4
4
  "description": "A package that performs build time transforms for Griffel",
5
5
  "license": "MIT",
6
6
  "repository": {
package/transform.js CHANGED
@@ -599,6 +599,16 @@ function batchEvaluator(sourceCode, filename, styleCalls, evaluationRules, resol
599
599
  evaluationResults
600
600
  };
601
601
  }
602
+ const Z_INDEX_DEFAULTS = {
603
+ zIndexBackground: 0,
604
+ zIndexContent: 1,
605
+ zIndexOverlay: 1e3,
606
+ zIndexPopup: 2e3,
607
+ zIndexMessages: 3e3,
608
+ zIndexFloating: 4e3,
609
+ zIndexPriority: 5e3,
610
+ zIndexDebug: 6e3
611
+ };
602
612
  function evaluateTemplateLiteralWithTokens(node) {
603
613
  let result = "";
604
614
  for (let i = 0; i < node.quasis.length; i++) {
@@ -606,7 +616,9 @@ function evaluateTemplateLiteralWithTokens(node) {
606
616
  if (i < node.expressions.length) {
607
617
  const expression = node.expressions[i];
608
618
  if (expression.type === "MemberExpression" && expression.object.type === "Identifier" && expression.object.name === "tokens" && expression.property.type === "Identifier" && !expression.computed) {
609
- result += `var(--${expression.property.name})`;
619
+ const name = expression.property.name;
620
+ const fallback = Z_INDEX_DEFAULTS[name];
621
+ result += fallback !== void 0 ? `var(--${name}, ${fallback})` : `var(--${name})`;
610
622
  } else {
611
623
  return DEOPT;
612
624
  }
@@ -616,7 +628,9 @@ function evaluateTemplateLiteralWithTokens(node) {
616
628
  }
617
629
  function evaluateTokensMemberExpression(node) {
618
630
  if (node.object.type === "Identifier" && node.object.name === "tokens" && node.property.type === "Identifier" && !node.computed) {
619
- return `var(--${node.property.name})`;
631
+ const name = node.property.name;
632
+ const fallback = Z_INDEX_DEFAULTS[name];
633
+ return fallback !== void 0 ? `var(--${name}, ${fallback})` : `var(--${name})`;
620
634
  } else {
621
635
  return DEOPT;
622
636
  }
@@ -733,10 +747,13 @@ function transformSync(sourceCode, options) {
733
747
  resolveModule,
734
748
  classNameHashSalt = "",
735
749
  generateMetadata = false,
736
- modules = ["@griffel/core", "@griffel/react", "@fluentui/react-components"],
750
+ importsToTransform = ["@griffel/core", "@griffel/react", "@fluentui/react-components"],
751
+ functionsToTransform = ["makeStyles", "makeResetStyles", "makeStaticStyles"],
737
752
  evaluationRules = [{ action: perfIssues ? wrapWithPerfIssues(shakerEvaluator, perfIssues) : shakerEvaluator }],
738
753
  astEvaluationPlugins = [fluentTokensPlugin]
739
754
  } = options;
755
+ const importsToTransformSet = new Set(importsToTransform);
756
+ const functionsToTransformSet = new Set(functionsToTransform);
740
757
  if (!filename) {
741
758
  throw new Error('Transform error: "filename" option is required');
742
759
  }
@@ -752,7 +769,7 @@ function transformSync(sourceCode, options) {
752
769
  const magicString = new MagicString(sourceCode);
753
770
  const programAst = parseResult.program;
754
771
  const hasGriffelImports = parseResult.module.staticImports.some(
755
- (si) => modules.includes(si.moduleRequest.value) && si.entries.some((e) => e.importName.kind === "Name" && RUNTIME_IDENTIFIERS.has(e.importName.name))
772
+ (si) => importsToTransformSet.has(si.moduleRequest.value) && si.entries.some((e) => e.importName.kind === "Name" && functionsToTransformSet.has(e.importName.name))
756
773
  );
757
774
  if (!hasGriffelImports) {
758
775
  return { code: sourceCode, usedProcessing: false, usedVMForEvaluation: false };
@@ -772,7 +789,7 @@ function transformSync(sourceCode, options) {
772
789
  return;
773
790
  }
774
791
  const importSource = declaration.importNode.source.value;
775
- if (!modules.includes(importSource)) {
792
+ if (!importsToTransformSet.has(importSource)) {
776
793
  return;
777
794
  }
778
795
  const imported = declaration.node.imported;
@@ -780,7 +797,7 @@ function transformSync(sourceCode, options) {
780
797
  return;
781
798
  }
782
799
  const importedName = imported.name;
783
- if (!RUNTIME_IDENTIFIERS.has(importedName)) {
800
+ if (!functionsToTransformSet.has(importedName)) {
784
801
  return;
785
802
  }
786
803
  const functionKind = importedName;
@@ -841,7 +858,7 @@ function transformSync(sourceCode, options) {
841
858
  programAst,
842
859
  astEvaluationPlugins
843
860
  );
844
- for (let i = 0; i < styleCalls.length; i++) {
861
+ for (let i = styleCalls.length - 1; i >= 0; i--) {
845
862
  const styleCall = styleCalls[i];
846
863
  const evaluationResult = evaluationResults[i];
847
864
  switch (styleCall.functionKind) {
@@ -12,7 +12,9 @@ export type TransformOptions = {
12
12
  */
13
13
  generateMetadata?: boolean;
14
14
  /** Defines set of modules and imports handled by a transformPlugin. */
15
- modules?: string[];
15
+ importsToTransform?: string[];
16
+ /** Defines the set of function names that should be treated as Griffel style calls. */
17
+ functionsToTransform?: FunctionKinds[];
16
18
  /** The set of rules that defines how the matched files will be transformed during the evaluation. */
17
19
  evaluationRules?: EvalRule[];
18
20
  /** Plugins for extending AST evaluation with custom node handling. */
@@ -30,7 +32,9 @@ export type TransformResult = {
30
32
  usedVMForEvaluation: boolean;
31
33
  perfIssues?: TransformPerfIssue[];
32
34
  };
35
+ type FunctionKinds = 'makeStyles' | 'makeResetStyles' | 'makeStaticStyles';
33
36
  /**
34
37
  * Transforms passed source code with oxc-parser and oxc-walker instead of Babel.
35
38
  */
36
39
  export declare function transformSync(sourceCode: string, options: TransformOptions): TransformResult;
40
+ export {};