@stylexjs/babel-plugin 0.18.0 → 0.18.1
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/lib/index.browser.js +27 -0
- package/lib/index.js +27 -0
- package/lib/utils/state-manager.d.ts +2 -0
- package/lib/utils/state-manager.js.flow +1 -0
- package/package.json +5 -5
package/lib/index.browser.js
CHANGED
|
@@ -1533,6 +1533,7 @@ class StateManager {
|
|
|
1533
1533
|
const enableLegacyValueFlipping = logAndDefault(boolean(), options.enableLegacyValueFlipping ?? defaultOptions.enableLegacyValueFlipping, false, 'options.enableLegacyValueFlipping');
|
|
1534
1534
|
const enableLogicalStylesPolyfill = logAndDefault(boolean(), options.enableLogicalStylesPolyfill ?? defaultOptions.enableLogicalStylesPolyfill, false, 'options.enableLogicalStylesPolyfill');
|
|
1535
1535
|
const enableLTRRTLComments = logAndDefault(boolean(), options.enableLTRRTLComments ?? defaultOptions.enableLTRRTLComments, false, 'options.enableLTRRTLComments');
|
|
1536
|
+
const sxPropName = logAndDefault(unionOf(string(), literal(false)), options.sxPropName ?? 'sx', 'sx', 'options.sxPropName');
|
|
1536
1537
|
const test = logAndDefault(boolean(), options.test ?? defaultOptions.test, false, 'options.test');
|
|
1537
1538
|
const configRuntimeInjection = logAndDefault(checkRuntimeInjection, options.runtimeInjection ?? false, false, 'options.runtimeInjection');
|
|
1538
1539
|
const runtimeInjection = configRuntimeInjection === true ? DEFAULT_INJECT_PATH : configRuntimeInjection === false ? undefined : configRuntimeInjection;
|
|
@@ -1573,6 +1574,7 @@ class StateManager {
|
|
|
1573
1574
|
enableLegacyValueFlipping,
|
|
1574
1575
|
enableLogicalStylesPolyfill,
|
|
1575
1576
|
enableLTRRTLComments,
|
|
1577
|
+
sxPropName,
|
|
1576
1578
|
importSources,
|
|
1577
1579
|
rewriteAliases: typeof options.rewriteAliases === 'boolean' ? options.rewriteAliases : false,
|
|
1578
1580
|
runtimeInjection,
|
|
@@ -9308,6 +9310,31 @@ function styleXTransform() {
|
|
|
9308
9310
|
});
|
|
9309
9311
|
}
|
|
9310
9312
|
},
|
|
9313
|
+
JSXOpeningElement(path) {
|
|
9314
|
+
const sxPropName = state.options.sxPropName;
|
|
9315
|
+
if (sxPropName === false) {
|
|
9316
|
+
return;
|
|
9317
|
+
}
|
|
9318
|
+
const node = path.node;
|
|
9319
|
+
if (node.name.type !== 'JSXIdentifier' || typeof node.name.name !== 'string' || node.name.name[0] !== node.name.name[0].toLowerCase()) {
|
|
9320
|
+
return;
|
|
9321
|
+
}
|
|
9322
|
+
for (const attr of path.get('attributes')) {
|
|
9323
|
+
if (!attr.isJSXAttribute() || !attr.get('name').isJSXIdentifier() || attr.get('name').node.name !== sxPropName) {
|
|
9324
|
+
continue;
|
|
9325
|
+
}
|
|
9326
|
+
const valuePath = attr.get('value');
|
|
9327
|
+
if (!valuePath.isJSXExpressionContainer()) {
|
|
9328
|
+
continue;
|
|
9329
|
+
}
|
|
9330
|
+
const value = valuePath.get('expression');
|
|
9331
|
+
if (value.isJSXEmptyExpression()) {
|
|
9332
|
+
continue;
|
|
9333
|
+
}
|
|
9334
|
+
attr.replaceWith(undefined(callExpression(memberExpression(identifier('stylex'), identifier('props')), [value.node])));
|
|
9335
|
+
break;
|
|
9336
|
+
}
|
|
9337
|
+
},
|
|
9311
9338
|
CallExpression(path) {
|
|
9312
9339
|
const parentPath = path.parentPath;
|
|
9313
9340
|
if (parentPath.isVariableDeclarator()) {
|
package/lib/index.js
CHANGED
|
@@ -419,6 +419,7 @@ class StateManager {
|
|
|
419
419
|
const enableLegacyValueFlipping = logAndDefault(boolean(), options.enableLegacyValueFlipping ?? defaultOptions.enableLegacyValueFlipping, false, 'options.enableLegacyValueFlipping');
|
|
420
420
|
const enableLogicalStylesPolyfill = logAndDefault(boolean(), options.enableLogicalStylesPolyfill ?? defaultOptions.enableLogicalStylesPolyfill, false, 'options.enableLogicalStylesPolyfill');
|
|
421
421
|
const enableLTRRTLComments = logAndDefault(boolean(), options.enableLTRRTLComments ?? defaultOptions.enableLTRRTLComments, false, 'options.enableLTRRTLComments');
|
|
422
|
+
const sxPropName = logAndDefault(unionOf(string(), literal(false)), options.sxPropName ?? 'sx', 'sx', 'options.sxPropName');
|
|
422
423
|
const test = logAndDefault(boolean(), options.test ?? defaultOptions.test, false, 'options.test');
|
|
423
424
|
const configRuntimeInjection = logAndDefault(checkRuntimeInjection, options.runtimeInjection ?? false, false, 'options.runtimeInjection');
|
|
424
425
|
const runtimeInjection = configRuntimeInjection === true ? DEFAULT_INJECT_PATH : configRuntimeInjection === false ? undefined : configRuntimeInjection;
|
|
@@ -459,6 +460,7 @@ class StateManager {
|
|
|
459
460
|
enableLegacyValueFlipping,
|
|
460
461
|
enableLogicalStylesPolyfill,
|
|
461
462
|
enableLTRRTLComments,
|
|
463
|
+
sxPropName,
|
|
462
464
|
importSources,
|
|
463
465
|
rewriteAliases: typeof options.rewriteAliases === 'boolean' ? options.rewriteAliases : false,
|
|
464
466
|
runtimeInjection,
|
|
@@ -8190,6 +8192,31 @@ function styleXTransform() {
|
|
|
8190
8192
|
});
|
|
8191
8193
|
}
|
|
8192
8194
|
},
|
|
8195
|
+
JSXOpeningElement(path) {
|
|
8196
|
+
const sxPropName = state.options.sxPropName;
|
|
8197
|
+
if (sxPropName === false) {
|
|
8198
|
+
return;
|
|
8199
|
+
}
|
|
8200
|
+
const node = path.node;
|
|
8201
|
+
if (node.name.type !== 'JSXIdentifier' || typeof node.name.name !== 'string' || node.name.name[0] !== node.name.name[0].toLowerCase()) {
|
|
8202
|
+
return;
|
|
8203
|
+
}
|
|
8204
|
+
for (const attr of path.get('attributes')) {
|
|
8205
|
+
if (!attr.isJSXAttribute() || !attr.get('name').isJSXIdentifier() || attr.get('name').node.name !== sxPropName) {
|
|
8206
|
+
continue;
|
|
8207
|
+
}
|
|
8208
|
+
const valuePath = attr.get('value');
|
|
8209
|
+
if (!valuePath.isJSXExpressionContainer()) {
|
|
8210
|
+
continue;
|
|
8211
|
+
}
|
|
8212
|
+
const value = valuePath.get('expression');
|
|
8213
|
+
if (value.isJSXEmptyExpression()) {
|
|
8214
|
+
continue;
|
|
8215
|
+
}
|
|
8216
|
+
attr.replaceWith(t__namespace.jsxSpreadAttribute(t__namespace.callExpression(t__namespace.memberExpression(t__namespace.identifier('stylex'), t__namespace.identifier('props')), [value.node])));
|
|
8217
|
+
break;
|
|
8218
|
+
}
|
|
8219
|
+
},
|
|
8193
8220
|
CallExpression(path) {
|
|
8194
8221
|
const parentPath = path.parentPath;
|
|
8195
8222
|
if (parentPath.isVariableDeclarator()) {
|
|
@@ -61,6 +61,7 @@ export type StyleXOptions = Readonly<
|
|
|
61
61
|
enableLogicalStylesPolyfill?: boolean;
|
|
62
62
|
enableLTRRTLComments?: boolean;
|
|
63
63
|
enableMinifiedKeys?: boolean;
|
|
64
|
+
sxPropName?: string | false;
|
|
64
65
|
importSources: ReadonlyArray<
|
|
65
66
|
string | Readonly<{ from: string; as: string }>
|
|
66
67
|
>;
|
|
@@ -88,6 +89,7 @@ export type StyleXOptions = Readonly<
|
|
|
88
89
|
enableLogicalStylesPolyfill?: boolean;
|
|
89
90
|
enableLTRRTLComments?: boolean;
|
|
90
91
|
enableMinifiedKeys?: boolean;
|
|
92
|
+
sxPropName?: string | false;
|
|
91
93
|
importSources: ReadonlyArray<
|
|
92
94
|
string | Readonly<{ from: string; as: string }>
|
|
93
95
|
>;
|
|
@@ -59,6 +59,7 @@ export type StyleXOptions = $ReadOnly<{
|
|
|
59
59
|
enableLogicalStylesPolyfill?: boolean,
|
|
60
60
|
enableLTRRTLComments?: boolean,
|
|
61
61
|
enableMinifiedKeys?: boolean,
|
|
62
|
+
sxPropName?: string | false,
|
|
62
63
|
importSources: $ReadOnlyArray<
|
|
63
64
|
string | $ReadOnly<{ from: string, as: string }>,
|
|
64
65
|
>,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stylexjs/babel-plugin",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.1",
|
|
4
4
|
"description": "StyleX babel plugin.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"browser": "lib/index.browser.js",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"@babel/traverse": "^7.26.8",
|
|
24
24
|
"@babel/types": "^7.26.8",
|
|
25
25
|
"@dual-bundle/import-meta-resolve": "^4.1.0",
|
|
26
|
-
"@stylexjs/shared": "0.18.
|
|
27
|
-
"@stylexjs/stylex": "0.18.
|
|
26
|
+
"@stylexjs/shared": "0.18.1",
|
|
27
|
+
"@stylexjs/stylex": "0.18.1",
|
|
28
28
|
"postcss-value-parser": "^4.1.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"@rollup/plugin-replace": "^6.0.1",
|
|
37
37
|
"babel-plugin-syntax-hermes-parser": "^0.32.1",
|
|
38
38
|
"path-browserify": "^1.0.1",
|
|
39
|
-
"rollup": "^4.
|
|
40
|
-
"scripts": "0.18.
|
|
39
|
+
"rollup": "^4.59.0",
|
|
40
|
+
"scripts": "0.18.1"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
43
|
"flow_modules/*",
|