Skip to content

Commit c49d1a3

Browse files
author
Anay Bhakat
committed
refactor: Export constants directly and remove re-exports
- Export LOGICAL_FLOAT_START_VAR and LOGICAL_FLOAT_END_VAR directly from legacy-expand-shorthands - Remove unnecessary re-exports from preprocess-rules index - Update imports to be more direct - Update test snapshots
1 parent a0af739 commit c49d1a3

File tree

4 files changed

+8
-26
lines changed

4 files changed

+8
-26
lines changed

packages/@stylexjs/babel-plugin/__tests__/transform-process-test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ describe('@stylexjs/babel-plugin', () => {
395395
"paddingInlineEnd-kwRFfy": "paddingInlineEnd-x1q3ajuy",
396396
"paddingBottom-kGO01o": "paddingBottom-xs9asl8",
397397
"paddingInlineStart-kZCmMZ": "paddingInlineStart-x1gx403c",
398-
"float-kyUFMd": "float-x1vdj7i2",
398+
"float-kyUFMd": "float-x1kmio9f",
399399
$$css: "app/main.js:23"
400400
}
401401
};"
@@ -418,7 +418,8 @@ describe('@stylexjs/babel-plugin', () => {
418418
}
419419
:root, .xsg933n{--blue-xpqh4lw:blue;}
420420
:root, .xbiwvf9{--small-x19twipt:2px;--medium-xypjos2:4px;--large-x1ec7iuc:8px;}
421-
.float-x1vdj7i2:not(#\\#){float:var(--1t497je)}
421+
/* @ltr begin */.float-x1kmio9f:not(#\\#){float:left}/* @ltr end */
422+
/* @rtl begin */.float-x1kmio9f:not(#\\#){float:var(--1bs9lmi)}/* @rtl end */
422423
/* @ltr begin */.marginInlineStart-xqsn43r:not(#\\#){margin-left:20px}/* @ltr end */
423424
/* @rtl begin */.marginInlineStart-xqsn43r:not(#\\#){margin-right:20px}/* @rtl end */
424425
/* @ltr begin */.marginInlineEnd-x3aesyq:not(#\\#){margin-right:20px}/* @ltr end */

packages/@stylexjs/babel-plugin/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import transformStyleXViewTransitionClass from './visitors/stylex-view-transitio
3535
import {
3636
LOGICAL_FLOAT_START_VAR,
3737
LOGICAL_FLOAT_END_VAR,
38-
} from './shared/preprocess-rules';
38+
} from './shared/preprocess-rules/legacy-expand-shorthands';
3939

4040
const NAME = 'stylex';
4141

packages/@stylexjs/babel-plugin/src/shared/preprocess-rules/index.js

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010
import type { StyleXOptions, TStyleValue } from '../common-types';
1111

1212
import applicationOrder from './application-order';
13-
import legacyExpandShorthands, {
14-
processProperty,
15-
LOGICAL_FLOAT_START_VAR,
16-
LOGICAL_FLOAT_END_VAR,
17-
} from './legacy-expand-shorthands';
13+
import legacyExpandShorthands from './legacy-expand-shorthands';
1814
import propertySpecificity from './property-specificity';
1915

2016
const expansions = {
@@ -44,18 +40,6 @@ export default function flatMapExpandedShorthands(
4440
key = key.slice(4, -1);
4541
}
4642

47-
// For legacy-expand-shorthands, use the new processProperty function
48-
// which handles both logical float/clear values and regular expansions
49-
if (options.styleResolution === 'legacy-expand-shorthands') {
50-
if (Array.isArray(value)) {
51-
throw new Error(
52-
'Cannot use fallbacks for shorthands. Use the expansion instead.',
53-
);
54-
}
55-
return processProperty(key, value);
56-
}
57-
58-
// For other style resolutions, use the original logic
5943
const expansion: (
6044
string | number | null,
6145
) => $ReadOnlyArray<[string, TStyleValue]> =
@@ -70,6 +54,3 @@ export default function flatMapExpandedShorthands(
7054
}
7155
return [[key, value]];
7256
}
73-
74-
// Export the CSS custom property variable names for use in CSS generation
75-
export { LOGICAL_FLOAT_START_VAR, LOGICAL_FLOAT_END_VAR };

packages/@stylexjs/babel-plugin/src/shared/preprocess-rules/legacy-expand-shorthands.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import splitValue from '../utils/split-css-value';
1313
import hash from '../hash';
1414

1515
// Generate hashed custom property names for logical float values using existing hash function
16-
const LOGICAL_FLOAT_START_VAR = `--${hash('logical-float-start')}`;
17-
const LOGICAL_FLOAT_END_VAR = `--${hash('logical-float-end')}`;
16+
export const LOGICAL_FLOAT_START_VAR = `--${hash('logical-float-start')}`;
17+
export const LOGICAL_FLOAT_END_VAR = `--${hash('logical-float-end')}`;
1818

1919
// Function to process float and clear properties with logical values
2020
function processLogicalFloatValue(
@@ -567,4 +567,4 @@ function processProperty(property: string, value: TStyleValue): TReturn {
567567

568568
// Export both the expansions object and the processing function
569569
export default expansions as typeof expansions;
570-
export { processProperty, LOGICAL_FLOAT_START_VAR, LOGICAL_FLOAT_END_VAR };
570+
export { processProperty };

0 commit comments

Comments
 (0)