@stylexjs/babel-plugin 0.10.1 → 0.11.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.js CHANGED
@@ -685,118 +685,6 @@ function requireLib$1 () {
685
685
 
686
686
  var libExports = requireLib$1();
687
687
 
688
- function isArrayExpression(path, props) {
689
- return path.isArrayExpression(props);
690
- }
691
- function isArrowFunctionExpression(path, props) {
692
- return path.isArrowFunctionExpression(props);
693
- }
694
- function isBinaryExpression(path, props) {
695
- return path.isBinaryExpression(props);
696
- }
697
- function isBooleanLiteral(path, props) {
698
- return path.isBooleanLiteral(props);
699
- }
700
- function isCallExpression(path, props) {
701
- return path.isCallExpression(props);
702
- }
703
- function isClass(path, props) {
704
- return path.isClass(props);
705
- }
706
- function isConditionalExpression(path, props) {
707
- return path.isConditionalExpression(props);
708
- }
709
- function isExportDefaultDeclaration(path, props) {
710
- return path.isExportDefaultDeclaration(props);
711
- }
712
- function isExportNamedDeclaration(path, props) {
713
- return path.isExportNamedDeclaration(props);
714
- }
715
- function isExpression(path, props) {
716
- return path.isExpression(props);
717
- }
718
- function isExpressionStatement(path, props) {
719
- return path.isExpressionStatement(props);
720
- }
721
- function isExpressionWrapper(path, props) {
722
- return path.isExpressionWrapper(props);
723
- }
724
- function isFunction(path, props) {
725
- return path.isFunction(props);
726
- }
727
- function isIdentifier(path, props) {
728
- return path.isIdentifier(props);
729
- }
730
- function isImportDeclaration(path, props) {
731
- return path.isImportDeclaration(props);
732
- }
733
- function isImportDefaultSpecifier(path, props) {
734
- return path.isImportDefaultSpecifier(props);
735
- }
736
- function isImportNamespaceSpecifier(path, props) {
737
- return path.isImportNamespaceSpecifier(props);
738
- }
739
- function isImportSpecifier(path, props) {
740
- return path.isImportSpecifier(props);
741
- }
742
- function isLogicalExpression(path, props) {
743
- return path.isLogicalExpression(props);
744
- }
745
- function isMemberExpression(path, props) {
746
- return path.isMemberExpression(props);
747
- }
748
- function isNullLiteral(path, props) {
749
- return path.isNullLiteral(props);
750
- }
751
- function isNumericLiteral(path, props) {
752
- return path.isNumericLiteral(props);
753
- }
754
- function isObjectExpression(path, props) {
755
- return path.isObjectExpression(props);
756
- }
757
- function isObjectMethod(path, props) {
758
- return path.isObjectMethod(props);
759
- }
760
- function isObjectProperty(path, props) {
761
- return path.isObjectProperty(props);
762
- }
763
- function isProgram(path, props) {
764
- return path.isProgram(props);
765
- }
766
- function isSequenceExpression(path, props) {
767
- return path.isSequenceExpression(props);
768
- }
769
- function isSpreadElement(path, props) {
770
- return path.isSpreadElement(props);
771
- }
772
- function isStatement(path, props) {
773
- return path.isStatement(props);
774
- }
775
- function isStringLiteral(path, props) {
776
- return path.isStringLiteral(props);
777
- }
778
- function isTSAsExpression(path, props) {
779
- return path.isTSAsExpression(props);
780
- }
781
- function isTaggedTemplateExpression(path, props) {
782
- return path.isTaggedTemplateExpression(props);
783
- }
784
- function isTemplateLiteral(path, props) {
785
- return path.isTemplateLiteral(props);
786
- }
787
- function isUnaryExpression(path, props) {
788
- return path.isUnaryExpression(props);
789
- }
790
- function isVariableDeclaration(path, props) {
791
- return path.isVariableDeclaration(props);
792
- }
793
- function isVariableDeclarator(path, props) {
794
- return path.isVariableDeclarator(props);
795
- }
796
- function isReferencedIdentifier(path, props) {
797
- return path.isReferencedIdentifier(props);
798
- }
799
-
800
688
  const CheckModuleResolution = unionOf3(object({
801
689
  type: literal('commonJS'),
802
690
  rootDir: unionOf(nullish(), string()),
@@ -844,6 +732,9 @@ class StateManager {
844
732
  setOptions(options) {
845
733
  const dev = logAndDefault(boolean(), options.dev ?? false, false, 'options.dev');
846
734
  const debug = logAndDefault(boolean(), options.debug ?? dev, false, 'options.debug');
735
+ const enableDebugClassNames = logAndDefault(boolean(), options.enableDebugClassNames ?? true, true, 'options.enableDebugClassNames');
736
+ const enableDebugDataProp = logAndDefault(boolean(), options.enableDebugDataProp ?? true, true, 'options.enableDebugDataProp');
737
+ const enableDevClassNames = logAndDefault(boolean(), options.enableDevClassNames ?? false, false, 'options.enableDevClassNames');
847
738
  const test = logAndDefault(boolean(), options.test ?? false, false, 'options.test');
848
739
  const configRuntimeInjection = logAndDefault(checkRuntimeInjection, options.runtimeInjection ?? dev, dev, 'options.runtimeInjection');
849
740
  const runtimeInjection = configRuntimeInjection === true ? DEFAULT_INJECT_PATH : configRuntimeInjection === false ? undefined : configRuntimeInjection;
@@ -865,18 +756,22 @@ class StateManager {
865
756
  }));
866
757
  const opts = {
867
758
  aliases,
868
- dev,
869
- debug,
870
- test,
871
- runtimeInjection,
872
759
  classNamePrefix,
873
- importSources,
760
+ debug,
874
761
  definedStylexCSSVariables: {},
762
+ dev,
763
+ enableDebugClassNames,
764
+ enableDebugDataProp,
765
+ enableDevClassNames,
875
766
  genConditionalClasses,
876
- useRemForFontSize,
767
+ importSources,
768
+ rewriteAliases: typeof options.rewriteAliases === 'boolean' ? options.rewriteAliases : false,
769
+ runtimeInjection,
877
770
  styleResolution,
771
+ test,
772
+ treeshakeCompensation,
878
773
  unstable_moduleResolution,
879
- treeshakeCompensation
774
+ useRemForFontSize
880
775
  };
881
776
  return opts;
882
777
  }
@@ -925,7 +820,7 @@ class StateManager {
925
820
  let targetImportIndex = -1;
926
821
  for (let i = 0; i < bodyPath.length; i++) {
927
822
  const statement = bodyPath[i];
928
- if (isImportDeclaration(statement)) {
823
+ if (statement.isImportDeclaration()) {
929
824
  targetImportIndex = i;
930
825
  if (statement.node.specifiers.find(s => s.type === 'ImportSpecifier' && s.local.type === 'Identifier' && s.local.name === identifier.name)) {
931
826
  break;
@@ -953,7 +848,7 @@ class StateManager {
953
848
  let targetImportIndex = -1;
954
849
  for (let i = 0; i < bodyPath.length; i++) {
955
850
  const statement = bodyPath[i];
956
- if (isImportDeclaration(statement)) {
851
+ if (statement.isImportDeclaration()) {
957
852
  targetImportIndex = i;
958
853
  if (statement.node.specifiers.find(s => s.type === 'ImportDefaultSpecifier' && s.local.type === 'Identifier' && s.local.name === identifier.name)) {
959
854
  break;
@@ -971,6 +866,14 @@ class StateManager {
971
866
  lastImport.insertAfter(t__namespace.variableDeclaration('var', [t__namespace.variableDeclarator(importName, identifier)]));
972
867
  return importName;
973
868
  }
869
+ get opts() {
870
+ return {
871
+ ...this.options
872
+ };
873
+ }
874
+ get isDebug() {
875
+ return !!this.options.debug;
876
+ }
974
877
  get isDev() {
975
878
  return !!this.options.dev;
976
879
  }
@@ -1081,7 +984,7 @@ class StateManager {
1081
984
  return;
1082
985
  }
1083
986
  const runtimeInjection = this.runtimeInjection;
1084
- const statementPath = path.parentPath != null && isProgram(path.parentPath) ? path : getProgramStatement(path);
987
+ const statementPath = path.parentPath != null && path.parentPath.isProgram() ? path : getProgramStatement(path);
1085
988
  let injectName;
1086
989
  if (this.injectImportInserted != null) {
1087
990
  injectName = this.injectImportInserted;
@@ -1167,7 +1070,7 @@ const addFileExtension = (importedFilePath, sourceFile) => {
1167
1070
  const matchesFileSuffix = allowedSuffix => filename => ['', ...EXTENSIONS].some(extension => filename.endsWith(`${allowedSuffix}${extension}`));
1168
1071
  const getProgramPath = path => {
1169
1072
  let programPath = path;
1170
- while (programPath != null && !isProgram(programPath)) {
1073
+ while (programPath != null && !programPath.isProgram()) {
1171
1074
  if (programPath.parentPath) {
1172
1075
  programPath = programPath.parentPath;
1173
1076
  } else {
@@ -1178,11 +1081,21 @@ const getProgramPath = path => {
1178
1081
  };
1179
1082
  const getProgramStatement = path => {
1180
1083
  let programPath = path;
1181
- while (programPath.parentPath != null && !isProgram(programPath.parentPath) && programPath.parentPath != null) {
1084
+ while (programPath.parentPath != null && !programPath.parentPath.isProgram() && programPath.parentPath != null) {
1182
1085
  programPath = programPath.parentPath;
1183
1086
  }
1184
1087
  return programPath;
1185
1088
  };
1089
+ function getRelativePath(from, to) {
1090
+ const relativePath = path.relative(path.parse(from).dir, to);
1091
+ return formatRelativePath(toPosixPath(relativePath));
1092
+ }
1093
+ function toPosixPath(filePath) {
1094
+ return filePath.split(path.sep).join(path.posix.sep);
1095
+ }
1096
+ function formatRelativePath(filePath) {
1097
+ return filePath.startsWith('.') ? filePath : './' + filePath;
1098
+ }
1186
1099
 
1187
1100
  function readImportDeclarations(path, state) {
1188
1101
  const {
@@ -1296,6 +1209,65 @@ function readRequires(path, state) {
1296
1209
  }
1297
1210
  }
1298
1211
 
1212
+ function getPackagePrefix(absolutePath) {
1213
+ const nodeModulesIndex = absolutePath.indexOf('node_modules');
1214
+ if (nodeModulesIndex !== -1) {
1215
+ const packageName = absolutePath.substring(nodeModulesIndex + 'node_modules'.length + 1);
1216
+ return packageName.split(path.sep)[0];
1217
+ }
1218
+ return undefined;
1219
+ }
1220
+ function getShortPath(relativePath) {
1221
+ return relativePath.split(path.sep).slice(-2).join('/');
1222
+ }
1223
+ function createShortFilename(absolutePath, state) {
1224
+ const isHaste = state.options.unstable_moduleResolution?.type === 'haste';
1225
+ const relativePath = path.relative(process.cwd(), absolutePath);
1226
+ const packagePrefix = getPackagePrefix(absolutePath);
1227
+ if (packagePrefix) {
1228
+ const shortPath = getShortPath(relativePath);
1229
+ return `${packagePrefix}:${shortPath}`;
1230
+ } else {
1231
+ if (isHaste) {
1232
+ return path.basename(absolutePath);
1233
+ }
1234
+ return getShortPath(relativePath);
1235
+ }
1236
+ }
1237
+ function addSourceMapData(obj, babelPath, state) {
1238
+ const result = {};
1239
+ for (const [key, value] of Object.entries(obj)) {
1240
+ const currentFile = babelPath.hub.file;
1241
+ const sourceMap = currentFile.codeMap;
1242
+ const styleNodePath = babelPath.get('arguments.0.properties').find(prop => {
1243
+ return prop.node.key.name === key || String(prop.node.key.value) === key;
1244
+ });
1245
+ if (styleNodePath) {
1246
+ const generatedLineNumber = styleNodePath.node.loc?.start.line;
1247
+ let originalLineNumber = generatedLineNumber;
1248
+ if (sourceMap && originalLineNumber) {
1249
+ const originalPosition = sourceMap.originalPositionFor({
1250
+ line: generatedLineNumber,
1251
+ column: styleNodePath.node.loc?.start.column
1252
+ });
1253
+ if (originalPosition && originalPosition.line !== null) {
1254
+ originalLineNumber = originalPosition.line;
1255
+ } else {
1256
+ console.warn(`Could not determine original line number for key: ${key}`);
1257
+ }
1258
+ }
1259
+ const shortFilename = createShortFilename(currentFile.opts.filename || '', state);
1260
+ result[key] = {
1261
+ ...value,
1262
+ $$css: shortFilename !== '' && originalLineNumber ? `${shortFilename}:${originalLineNumber}` : true
1263
+ };
1264
+ } else {
1265
+ result[key] = value;
1266
+ }
1267
+ }
1268
+ return result;
1269
+ }
1270
+
1299
1271
  function namespaceToDevClassName(namespace, varName, filename) {
1300
1272
  const basename = path.basename(filename).split('.')[0];
1301
1273
  const className = `${basename}__${varName ? `${varName}.` : ''}${namespace}`;
@@ -1327,14 +1299,11 @@ function convertToTestStyles(obj, varName, state) {
1327
1299
  function convertObjectToAST(obj) {
1328
1300
  return t__namespace.objectExpression(Object.entries(obj).map(_ref => {
1329
1301
  let [key, value] = _ref;
1330
- return value instanceof shared.IncludedStyles ? t__namespace.spreadElement(value.astNode) : t__namespace.objectProperty(canBeIdentifier(key) ? t__namespace.identifier(key) : t__namespace.stringLiteral(key), typeof value === 'string' ? t__namespace.stringLiteral(value) : typeof value === 'number' ? t__namespace.numericLiteral(value) : typeof value === 'boolean' ? t__namespace.booleanLiteral(value) : value === null ? t__namespace.nullLiteral() : convertObjectToAST(value));
1302
+ return t__namespace.objectProperty(canBeIdentifier(key) ? t__namespace.identifier(key) : t__namespace.stringLiteral(key), typeof value === 'string' ? t__namespace.stringLiteral(value) : typeof value === 'number' ? t__namespace.numericLiteral(value) : typeof value === 'boolean' ? t__namespace.booleanLiteral(value) : value === null ? t__namespace.nullLiteral() : convertObjectToAST(value));
1331
1303
  }));
1332
1304
  }
1333
1305
  function removeObjectsWithSpreads(obj) {
1334
- return Object.fromEntries(Object.entries(obj).filter(_ref2 => {
1335
- let [_key, value] = _ref2;
1336
- return Object.values(value).every(val => !(val instanceof shared.IncludedStyles));
1337
- }).filter(Boolean));
1306
+ return Object.fromEntries(Object.entries(obj).filter(Boolean));
1338
1307
  }
1339
1308
  function canBeIdentifier(str) {
1340
1309
  return str.match(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/) != null;
@@ -1395,13 +1364,13 @@ function evaluateImportedFile(filePath, namedExport, state, bindingPath) {
1395
1364
  traverse(astNode, {
1396
1365
  ExportNamedDeclaration(path) {
1397
1366
  const declaration = path.get('declaration');
1398
- if (isVariableDeclaration(declaration)) {
1367
+ if (declaration.isVariableDeclaration()) {
1399
1368
  const decls = declaration.get('declarations');
1400
1369
  const finder = decl => {
1401
- if (isVariableDeclarator(decl)) {
1370
+ if (decl.isVariableDeclarator()) {
1402
1371
  const id = decl.get('id');
1403
1372
  const init = decl.get('init');
1404
- if (isIdentifier(id) && id.node.name === namedExport && init != null && isExpression(init)) {
1373
+ if (id.isIdentifier() && id.node.name === namedExport && init != null && init.isExpression()) {
1405
1374
  result = evaluateCached(init, state);
1406
1375
  }
1407
1376
  }
@@ -1488,11 +1457,11 @@ function evaluateCached(path, state) {
1488
1457
  }
1489
1458
  function _evaluate(path, state) {
1490
1459
  if (!state.confident) return;
1491
- if (isArrowFunctionExpression(path)) {
1460
+ if (path.isArrowFunctionExpression()) {
1492
1461
  const body = path.get('body');
1493
1462
  const params = path.get('params');
1494
- const identParams = params.filter(param => isIdentifier(param)).map(paramPath => paramPath.node.name);
1495
- if (isExpression(body) && identParams.length === params.length) {
1463
+ const identParams = params.filter(param => param.isIdentifier()).map(paramPath => paramPath.node.name);
1464
+ if (body.isExpression() && identParams.length === params.length) {
1496
1465
  const expr = body;
1497
1466
  return function () {
1498
1467
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
@@ -1511,13 +1480,13 @@ function _evaluate(path, state) {
1511
1480
  };
1512
1481
  }
1513
1482
  }
1514
- if (isIdentifier(path)) {
1483
+ if (path.isIdentifier()) {
1515
1484
  const name = path.node.name;
1516
1485
  if (Object.keys(state.functions?.identifiers ?? {}).includes(name)) {
1517
1486
  return state.functions.identifiers[name];
1518
1487
  }
1519
1488
  }
1520
- if (isTSAsExpression(path)) {
1489
+ if (path.isTSAsExpression()) {
1521
1490
  const expr = path.get('expression');
1522
1491
  return evaluateCached(expr, state);
1523
1492
  }
@@ -1525,32 +1494,32 @@ function _evaluate(path, state) {
1525
1494
  const expr = path.get('expression');
1526
1495
  return evaluateCached(expr, state);
1527
1496
  }
1528
- if (isSequenceExpression(path)) {
1497
+ if (path.isSequenceExpression()) {
1529
1498
  const exprs = path.get('expressions');
1530
1499
  return evaluateCached(exprs[exprs.length - 1], state);
1531
1500
  }
1532
- if (isStringLiteral(path) || isNumericLiteral(path) || isBooleanLiteral(path)) {
1501
+ if (path.isStringLiteral() || path.isNumericLiteral() || path.isBooleanLiteral()) {
1533
1502
  return path.node.value;
1534
1503
  }
1535
- if (isNullLiteral(path)) {
1504
+ if (path.isNullLiteral()) {
1536
1505
  return null;
1537
1506
  }
1538
- if (isTemplateLiteral(path)) {
1507
+ if (path.isTemplateLiteral()) {
1539
1508
  return evaluateQuasis(path, path.node.quasis, state);
1540
1509
  }
1541
- const maybeTag = isTaggedTemplateExpression(path) && path.get('tag');
1542
- if (isTaggedTemplateExpression(path) && maybeTag && isMemberExpression(maybeTag)) {
1510
+ const maybeTag = path.isTaggedTemplateExpression() && path.get('tag');
1511
+ if (path.isTaggedTemplateExpression() && maybeTag && maybeTag.isMemberExpression()) {
1543
1512
  const tag = maybeTag;
1544
1513
  const object = tag.get('object');
1545
- if (isIdentifier(object)) {
1514
+ if (object.isIdentifier()) {
1546
1515
  const name = object.node.name;
1547
1516
  const property = tag.get('property');
1548
- if (name === 'String' && !path.scope.hasBinding(name) && isIdentifier(property) && property.node.name === 'raw') {
1517
+ if (name === 'String' && !path.scope.hasBinding(name) && property.isIdentifier() && property.node.name === 'raw') {
1549
1518
  return evaluateQuasis(path, path.node.quasi.quasis, state, true);
1550
1519
  }
1551
1520
  }
1552
1521
  }
1553
- if (isConditionalExpression(path)) {
1522
+ if (path.isConditionalExpression()) {
1554
1523
  const testResult = evaluateCached(path.get('test'), state);
1555
1524
  if (!state.confident) return;
1556
1525
  if (testResult) {
@@ -1559,10 +1528,10 @@ function _evaluate(path, state) {
1559
1528
  return evaluateCached(path.get('alternate'), state);
1560
1529
  }
1561
1530
  }
1562
- if (isExpressionWrapper(path)) {
1531
+ if (path.isExpressionWrapper()) {
1563
1532
  return evaluateCached(path.get('expression'), state);
1564
1533
  }
1565
- if (isMemberExpression(path) && !isCallExpression(path.parentPath, {
1534
+ if (path.isMemberExpression() && !path.parentPath.isCallExpression({
1566
1535
  callee: path.node
1567
1536
  })) {
1568
1537
  const object = evaluateCached(path.get('object'), state);
@@ -1576,25 +1545,25 @@ function _evaluate(path, state) {
1576
1545
  if (!state.confident) {
1577
1546
  return;
1578
1547
  }
1579
- } else if (isIdentifier(propPath)) {
1548
+ } else if (propPath.isIdentifier()) {
1580
1549
  property = propPath.node.name;
1581
- } else if (isStringLiteral(propPath)) {
1550
+ } else if (propPath.isStringLiteral()) {
1582
1551
  property = propPath.node.value;
1583
1552
  } else {
1584
1553
  return deopt(propPath, state, UNEXPECTED_MEMBER_LOOKUP);
1585
1554
  }
1586
1555
  return object[property];
1587
1556
  }
1588
- if (isReferencedIdentifier(path)) {
1557
+ if (path.isReferencedIdentifier()) {
1589
1558
  const binding = path.scope?.getBinding(path.node.name);
1590
1559
  const bindingPath = binding?.path;
1591
- if (binding && bindingPath && !isImportDefaultSpecifier(bindingPath) && !isImportNamespaceSpecifier(bindingPath) && isImportSpecifier(bindingPath)) {
1560
+ if (binding && bindingPath && !bindingPath.isImportDefaultSpecifier() && !bindingPath.isImportNamespaceSpecifier() && bindingPath.isImportSpecifier()) {
1592
1561
  const importSpecifierPath = bindingPath;
1593
1562
  const importSpecifierNode = importSpecifierPath.node;
1594
1563
  const imported = importSpecifierNode.imported;
1595
1564
  const importedName = imported.type === 'Identifier' ? imported.name : imported.value;
1596
1565
  const importPath = binding.path.parentPath;
1597
- if (importPath && isImportDeclaration(importPath)) {
1566
+ if (importPath && importPath.isImportDeclaration()) {
1598
1567
  const absPath = state.traversalState.importPathResolver(importPath.node.source.value);
1599
1568
  if (!absPath) {
1600
1569
  return deopt(binding.path, state, IMPORT_PATH_RESOLUTION_ERROR);
@@ -1612,7 +1581,7 @@ function _evaluate(path, state) {
1612
1581
  }
1613
1582
  }
1614
1583
  }
1615
- if (binding && bindingPath && isImportDefaultSpecifier(bindingPath)) {
1584
+ if (binding && bindingPath && bindingPath.isImportDefaultSpecifier()) {
1616
1585
  deopt(binding.path, state, IMPORT_FILE_EVAL_ERROR);
1617
1586
  }
1618
1587
  if (binding && binding.constantViolations.length > 0) {
@@ -1639,14 +1608,14 @@ function _evaluate(path, state) {
1639
1608
  }
1640
1609
  }
1641
1610
  }
1642
- if (isUnaryExpression(path, {
1611
+ if (path.isUnaryExpression({
1643
1612
  prefix: true
1644
1613
  })) {
1645
1614
  if (path.node.operator === 'void') {
1646
1615
  return undefined;
1647
1616
  }
1648
1617
  const argument = path.get('argument');
1649
- if (path.node.operator === 'typeof' && (isFunction(argument) || isClass(argument))) {
1618
+ if (path.node.operator === 'typeof' && (argument.isFunction() || argument.isClass())) {
1650
1619
  return 'function';
1651
1620
  }
1652
1621
  const arg = evaluateCached(argument, state);
@@ -1668,7 +1637,7 @@ function _evaluate(path, state) {
1668
1637
  return deopt(path, state, UNSUPPORTED_OPERATOR(path.node.operator));
1669
1638
  }
1670
1639
  }
1671
- if (isArrayExpression(path)) {
1640
+ if (path.isArrayExpression()) {
1672
1641
  const arrPath = path;
1673
1642
  const arr = [];
1674
1643
  const elems = arrPath.get('elements');
@@ -1683,14 +1652,14 @@ function _evaluate(path, state) {
1683
1652
  }
1684
1653
  return arr;
1685
1654
  }
1686
- if (isObjectExpression(path)) {
1655
+ if (path.isObjectExpression()) {
1687
1656
  const obj = {};
1688
1657
  const props = path.get('properties');
1689
1658
  for (const prop of props) {
1690
- if (isObjectMethod(prop)) {
1659
+ if (prop.isObjectMethod()) {
1691
1660
  return deopt(prop, state, OBJECT_METHOD);
1692
1661
  }
1693
- if (isSpreadElement(prop)) {
1662
+ if (prop.isSpreadElement()) {
1694
1663
  const spreadExpression = evaluateCached(prop.get('argument'), state);
1695
1664
  if (!state.confident) {
1696
1665
  return deopt(prop, state, state.deoptReason ?? 'unknown error');
@@ -1698,7 +1667,7 @@ function _evaluate(path, state) {
1698
1667
  Object.assign(obj, spreadExpression);
1699
1668
  continue;
1700
1669
  }
1701
- if (isObjectProperty(prop)) {
1670
+ if (prop.isObjectProperty()) {
1702
1671
  const keyPath = prop.get('key');
1703
1672
  let key;
1704
1673
  if (prop.node.computed) {
@@ -1713,7 +1682,7 @@ function _evaluate(path, state) {
1713
1682
  return;
1714
1683
  }
1715
1684
  key = value;
1716
- } else if (isIdentifier(keyPath)) {
1685
+ } else if (keyPath.isIdentifier()) {
1717
1686
  key = keyPath.node.name;
1718
1687
  } else {
1719
1688
  key = keyPath.node.value;
@@ -1730,7 +1699,7 @@ function _evaluate(path, state) {
1730
1699
  }
1731
1700
  return obj;
1732
1701
  }
1733
- if (isLogicalExpression(path)) {
1702
+ if (path.isLogicalExpression()) {
1734
1703
  const stateForLeft = {
1735
1704
  ...state,
1736
1705
  deoptPath: null,
@@ -1800,7 +1769,7 @@ function _evaluate(path, state) {
1800
1769
  path.node.operator;
1801
1770
  }
1802
1771
  }
1803
- if (isBinaryExpression(path)) {
1772
+ if (path.isBinaryExpression()) {
1804
1773
  const left = evaluateCached(path.get('left'), state);
1805
1774
  if (!state.confident) return;
1806
1775
  const right = evaluateCached(path.get('right'), state);
@@ -1854,15 +1823,15 @@ function _evaluate(path, state) {
1854
1823
  return;
1855
1824
  }
1856
1825
  }
1857
- if (isCallExpression(path)) {
1826
+ if (path.isCallExpression()) {
1858
1827
  const callee = path.get('callee');
1859
1828
  let context;
1860
1829
  let func;
1861
- if (isIdentifier(callee) && !path.scope.getBinding(callee.node.name) && isValidCallee(callee.node.name)) {
1830
+ if (callee.isIdentifier() && !path.scope.getBinding(callee.node.name) && isValidCallee(callee.node.name)) {
1862
1831
  func = global[callee.node.name];
1863
- } else if (isIdentifier(callee) && state.functions.identifiers[callee.node.name]) {
1832
+ } else if (callee.isIdentifier() && state.functions.identifiers[callee.node.name]) {
1864
1833
  func = state.functions.identifiers[callee.node.name];
1865
- } else if (isIdentifier(callee)) {
1834
+ } else if (callee.isIdentifier()) {
1866
1835
  const maybeFunction = evaluateCached(callee, state);
1867
1836
  if (state.confident) {
1868
1837
  func = maybeFunction;
@@ -1870,10 +1839,10 @@ function _evaluate(path, state) {
1870
1839
  deopt(callee, state, NON_CONSTANT);
1871
1840
  }
1872
1841
  }
1873
- if (isMemberExpression(callee)) {
1842
+ if (callee.isMemberExpression()) {
1874
1843
  const object = callee.get('object');
1875
1844
  const property = callee.get('property');
1876
- if (isIdentifier(object) && isIdentifier(property)) {
1845
+ if (object.isIdentifier() && property.isIdentifier()) {
1877
1846
  if (isValidCallee(object.node.name) && !isInvalidMethod(property.node.name)) {
1878
1847
  context = global[object.node.name];
1879
1848
  func = context[property.node.name];
@@ -1882,11 +1851,11 @@ function _evaluate(path, state) {
1882
1851
  func = context[property.node.name];
1883
1852
  }
1884
1853
  }
1885
- if (isIdentifier(object) && isStringLiteral(property) && state.functions.memberExpressions[object.node.name] && state.functions.memberExpressions[object.node.name][property.node.value]) {
1854
+ if (object.isIdentifier() && property.isStringLiteral() && state.functions.memberExpressions[object.node.name] && state.functions.memberExpressions[object.node.name][property.node.value]) {
1886
1855
  context = state.functions.memberExpressions[object.node.name];
1887
1856
  func = context[property.node.value];
1888
1857
  }
1889
- if ((isStringLiteral(object) || isNumericLiteral(object)) && isIdentifier(property)) {
1858
+ if ((object.isStringLiteral() || object.isNumericLiteral()) && property.isIdentifier()) {
1890
1859
  const val = object.node.value;
1891
1860
  func = val[property.node.name];
1892
1861
  if (typeof val === 'string') {
@@ -1895,11 +1864,11 @@ function _evaluate(path, state) {
1895
1864
  }
1896
1865
  if (func == null) {
1897
1866
  const parsedObj = evaluate(object, state.traversalState, state.functions);
1898
- if (parsedObj.confident && isIdentifier(property)) {
1867
+ if (parsedObj.confident && property.isIdentifier()) {
1899
1868
  func = parsedObj.value[property.node.name];
1900
1869
  context = parsedObj.value;
1901
1870
  }
1902
- if (parsedObj.confident && isStringLiteral(property)) {
1871
+ if (parsedObj.confident && property.isStringLiteral()) {
1903
1872
  func = parsedObj.value[property.node.value];
1904
1873
  context = parsedObj.value;
1905
1874
  }
@@ -1926,7 +1895,7 @@ function evaluateQuasis(path, quasis, state) {
1926
1895
  let raw = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
1927
1896
  let str = '';
1928
1897
  let i = 0;
1929
- const exprs = isTemplateLiteral(path) ? path.get('expressions') : isTaggedTemplateExpression(path) ? path.get('quasi').get('expressions') : [];
1898
+ const exprs = path.isTemplateLiteral() ? path.get('expressions') : path.isTaggedTemplateExpression() ? path.get('quasi').get('expressions') : [];
1930
1899
  for (const elem of quasis) {
1931
1900
  if (!state.confident) break;
1932
1901
  str += raw ? elem.value.raw : elem.value.cooked;
@@ -2799,7 +2768,7 @@ function requireMessages () {
2799
2768
  Object.defineProperty(messages, "__esModule", {
2800
2769
  value: true
2801
2770
  });
2802
- messages.UNKNOWN_PROP_KEY = messages.UNKNOWN_NAMESPACE = messages.UNEXPECTED_ARGUMENT = messages.UNBOUND_STYLEX_CALL_VALUE = messages.ONLY_TOP_LEVEL_INCLUDES = messages.ONLY_TOP_LEVEL = messages.ONLY_NAMED_PARAMETERS_IN_DYNAMIC_STYLE_FUNCTIONS = messages.NO_PROJECT_ROOT_DIRECTORY = messages.NO_PARENT_PATH = messages.NO_CONDITIONAL_SHORTHAND = messages.NON_STATIC_VALUE = messages.NON_STATIC_KEYFRAME_VALUE = messages.NON_OBJECT_KEYFRAME = messages.NON_OBJECT_FOR_STYLEX_KEYFRAMES_CALL = messages.NON_OBJECT_FOR_STYLEX_CALL = messages.NON_EXPORT_NAMED_DECLARATION = messages.NON_CONTIGUOUS_VARS = messages.LOCAL_ONLY = messages.LINT_UNCLOSED_FUNCTION = messages.INVALID_SPREAD = messages.INVALID_PSEUDO_OR_AT_RULE = messages.INVALID_PSEUDO = messages.ILLEGAL_PROP_VALUE = messages.ILLEGAL_PROP_ARRAY_VALUE = messages.ILLEGAL_NESTED_PSEUDO = messages.ILLEGAL_NAMESPACE_VALUE = messages.ILLEGAL_NAMESPACE_TYPE = messages.ILLEGAL_ARG_LENGTH_FOR_KEYFRAMES = messages.ILLEGAL_ARGUMENT_LENGTH = messages.EXPECTED_FUNCTION_CALL = messages.ESCAPED_STYLEX_VALUE = messages.DUPLICATE_CONDITIONAL = messages.ANONYMOUS_THEME = void 0;
2771
+ messages.UNKNOWN_PROP_KEY = messages.UNKNOWN_NAMESPACE = messages.UNEXPECTED_ARGUMENT = messages.UNBOUND_STYLEX_CALL_VALUE = messages.ONLY_TOP_LEVEL = messages.ONLY_NAMED_PARAMETERS_IN_DYNAMIC_STYLE_FUNCTIONS = messages.NO_PROJECT_ROOT_DIRECTORY = messages.NO_PARENT_PATH = messages.NO_CONDITIONAL_SHORTHAND = messages.NON_STATIC_VALUE = messages.NON_STATIC_KEYFRAME_VALUE = messages.NON_OBJECT_KEYFRAME = messages.NON_OBJECT_FOR_STYLEX_KEYFRAMES_CALL = messages.NON_OBJECT_FOR_STYLEX_CALL = messages.NON_EXPORT_NAMED_DECLARATION = messages.NON_CONTIGUOUS_VARS = messages.LOCAL_ONLY = messages.LINT_UNCLOSED_FUNCTION = messages.INVALID_SPREAD = messages.INVALID_PSEUDO_OR_AT_RULE = messages.INVALID_PSEUDO = messages.ILLEGAL_PROP_VALUE = messages.ILLEGAL_PROP_ARRAY_VALUE = messages.ILLEGAL_NESTED_PSEUDO = messages.ILLEGAL_NAMESPACE_VALUE = messages.ILLEGAL_NAMESPACE_TYPE = messages.ILLEGAL_ARG_LENGTH_FOR_KEYFRAMES = messages.ILLEGAL_ARGUMENT_LENGTH = messages.EXPECTED_FUNCTION_CALL = messages.ESCAPED_STYLEX_VALUE = messages.DUPLICATE_CONDITIONAL = messages.ANONYMOUS_THEME = void 0;
2803
2772
  messages.ILLEGAL_ARGUMENT_LENGTH = 'stylex.create() should have 1 argument.';
2804
2773
  messages.ILLEGAL_ARG_LENGTH_FOR_KEYFRAMES = 'stylex.keyframes() should have 1 argument.';
2805
2774
  messages.NON_STATIC_VALUE = 'Only static values are allowed inside of a stylex.create() call.';
@@ -2826,7 +2795,6 @@ function requireMessages () {
2826
2795
  messages.UNEXPECTED_ARGUMENT = 'Unexpected argument passed to the stylex() function.';
2827
2796
  messages.EXPECTED_FUNCTION_CALL = 'Expected a simple function call but found something else.';
2828
2797
  messages.NO_PARENT_PATH = 'Unexpected AST node without a parent path.';
2829
- messages.ONLY_TOP_LEVEL_INCLUDES = 'stylex.include() is only at the top level of a style definition object.';
2830
2798
  messages.DUPLICATE_CONDITIONAL = 'The same pseudo selector or at-rule cannot be used more than once.';
2831
2799
  messages.NO_PROJECT_ROOT_DIRECTORY = 'The project root directory `rootDir` is not configured.';
2832
2800
  messages.NON_EXPORT_NAMED_DECLARATION = 'The return value of stylex.defineVars() must be bound to a named export.';
@@ -3009,13 +2977,13 @@ function evaluateStyleXCreateArg(path, traversalState) {
3009
2977
  identifiers: {},
3010
2978
  memberExpressions: {}
3011
2979
  };
3012
- if (!isObjectExpression(path)) {
2980
+ if (!path.isObjectExpression()) {
3013
2981
  return evaluate(path, traversalState, functions);
3014
2982
  }
3015
2983
  const value = {};
3016
2984
  const fns = {};
3017
2985
  for (const prop of path.get('properties')) {
3018
- if (!isObjectProperty(prop)) {
2986
+ if (!prop.isObjectProperty()) {
3019
2987
  return evaluate(path, traversalState, functions);
3020
2988
  }
3021
2989
  const objPropPath = prop;
@@ -3029,7 +2997,7 @@ function evaluateStyleXCreateArg(path, traversalState) {
3029
2997
  }
3030
2998
  const key = keyResult.value;
3031
2999
  const valPath = prop.get('value');
3032
- if (!isArrowFunctionExpression(valPath)) {
3000
+ if (!valPath.isArrowFunctionExpression()) {
3033
3001
  const val = evaluate(valPath, traversalState, functions);
3034
3002
  if (!val.confident) {
3035
3003
  return val;
@@ -3040,9 +3008,9 @@ function evaluateStyleXCreateArg(path, traversalState) {
3040
3008
  const fnPath = valPath;
3041
3009
  const allParams = fnPath.get('params');
3042
3010
  validateDynamicStyleParams(fnPath, allParams);
3043
- const params = allParams.filter(param => isIdentifier(param)).map(param => param.node);
3011
+ const params = allParams.filter(param => param.isIdentifier()).map(param => param.node);
3044
3012
  const fnBody = fnPath.get('body');
3045
- if (!isObjectExpression(fnBody)) {
3013
+ if (!fnBody.isObjectExpression()) {
3046
3014
  return evaluate(path, traversalState, functions);
3047
3015
  }
3048
3016
  const fnObjectBody = fnBody;
@@ -3082,13 +3050,13 @@ function evaluatePartialObjectRecursively(path, traversalState) {
3082
3050
  const inlineStyles = {};
3083
3051
  const props = path.get('properties');
3084
3052
  for (const prop of props) {
3085
- if (isObjectMethod(prop)) {
3053
+ if (prop.isObjectMethod()) {
3086
3054
  return {
3087
3055
  value: null,
3088
3056
  confident: false
3089
3057
  };
3090
3058
  }
3091
- if (isSpreadElement(prop)) {
3059
+ if (prop.isSpreadElement()) {
3092
3060
  const result = evaluate(prop.get('argument'), traversalState, functions);
3093
3061
  if (!result.confident) {
3094
3062
  return result;
@@ -3096,7 +3064,7 @@ function evaluatePartialObjectRecursively(path, traversalState) {
3096
3064
  Object.assign(obj, result.value);
3097
3065
  continue;
3098
3066
  }
3099
- if (isObjectProperty(prop)) {
3067
+ if (prop.isObjectProperty()) {
3100
3068
  const keyResult = evaluateObjKey(prop, traversalState, functions);
3101
3069
  if (!keyResult.confident) {
3102
3070
  return {
@@ -3110,7 +3078,7 @@ function evaluatePartialObjectRecursively(path, traversalState) {
3110
3078
  key = key.slice(4, -1);
3111
3079
  }
3112
3080
  const valuePath = prop.get('value');
3113
- if (isObjectExpression(valuePath)) {
3081
+ if (valuePath.isObjectExpression()) {
3114
3082
  const result = evaluatePartialObjectRecursively(valuePath, traversalState, functions, [...keyPath, key]);
3115
3083
  if (!result.confident) {
3116
3084
  return {
@@ -3164,7 +3132,7 @@ function evaluateObjKey(prop, traversalState, functions) {
3164
3132
  };
3165
3133
  }
3166
3134
  key = result.value;
3167
- } else if (isIdentifier(keyPath)) {
3135
+ } else if (keyPath.isIdentifier()) {
3168
3136
  key = keyPath.node.name;
3169
3137
  } else {
3170
3138
  key = keyPath.node.value;
@@ -3175,7 +3143,7 @@ function evaluateObjKey(prop, traversalState, functions) {
3175
3143
  };
3176
3144
  }
3177
3145
  function validateDynamicStyleParams(path, params) {
3178
- if (params.some(param => !isIdentifier(param))) {
3146
+ if (params.some(param => !param.isIdentifier())) {
3179
3147
  throw path.buildCodeFrameError(shared.messages.ONLY_NAMED_PARAMETERS_IN_DYNAMIC_STYLE_FUNCTIONS, SyntaxError);
3180
3148
  }
3181
3149
  }
@@ -3754,12 +3722,6 @@ function transformStyleXCreate(path, state) {
3754
3722
  }
3755
3723
  const identifiers = {};
3756
3724
  const memberExpressions = {};
3757
- state.stylexIncludeImport.forEach(name => {
3758
- identifiers[name] = {
3759
- fn: shared.include,
3760
- takesPath: true
3761
- };
3762
- });
3763
3725
  state.stylexFirstThatWorksImport.forEach(name => {
3764
3726
  identifiers[name] = {
3765
3727
  fn: shared.firstThatWorks
@@ -3774,10 +3736,6 @@ function transformStyleXCreate(path, state) {
3774
3736
  if (memberExpressions[name] == null) {
3775
3737
  memberExpressions[name] = {};
3776
3738
  }
3777
- memberExpressions[name].include = {
3778
- fn: shared.include,
3779
- takesPath: true
3780
- };
3781
3739
  memberExpressions[name].firstThatWorks = {
3782
3740
  fn: shared.firstThatWorks
3783
3741
  };
@@ -3817,21 +3775,27 @@ function transformStyleXCreate(path, state) {
3817
3775
  ...injectedInheritStyles
3818
3776
  };
3819
3777
  let varName = null;
3820
- if (isVariableDeclarator(path.parentPath)) {
3778
+ if (path.parentPath.isVariableDeclarator()) {
3821
3779
  const idNode = path.parentPath.node.id;
3822
3780
  if (idNode.type === 'Identifier') {
3823
3781
  varName = idNode.name;
3824
3782
  }
3825
3783
  }
3826
- if (state.isTest) {
3784
+ if (state.isDebug && state.opts.enableDebugDataProp) {
3827
3785
  compiledStyles = {
3828
- ...convertToTestStyles(compiledStyles, varName, state)
3786
+ ...addSourceMapData(compiledStyles, path, state)
3829
3787
  };
3830
- } else if (state.isDev) {
3788
+ }
3789
+ if (state.isDev && state.opts.enableDevClassNames) {
3831
3790
  compiledStyles = {
3832
3791
  ...injectDevClassNames(compiledStyles, varName, state)
3833
3792
  };
3834
3793
  }
3794
+ if (state.isTest) {
3795
+ compiledStyles = {
3796
+ ...convertToTestStyles(compiledStyles, varName, state)
3797
+ };
3798
+ }
3835
3799
  if (varName != null) {
3836
3800
  const stylesToRemember = removeObjectsWithSpreads(compiledStyles);
3837
3801
  state.styleMap.set(varName, stylesToRemember);
@@ -3944,11 +3908,11 @@ function transformStyleXCreate(path, state) {
3944
3908
  state.inStyleXCreate = false;
3945
3909
  }
3946
3910
  function validateStyleXCreate(path) {
3947
- if (path.parentPath == null || isExpressionStatement(path.parentPath)) {
3911
+ if (path.parentPath == null || path.parentPath.isExpressionStatement()) {
3948
3912
  throw path.buildCodeFrameError(shared.messages.UNBOUND_STYLEX_CALL_VALUE, SyntaxError);
3949
3913
  }
3950
3914
  const nearestStatement = findNearestStatementAncestor(path);
3951
- if (!isProgram(nearestStatement.parentPath) && !isExportNamedDeclaration(nearestStatement.parentPath)) {
3915
+ if (!nearestStatement.parentPath.isProgram() && !nearestStatement.parentPath.isExportNamedDeclaration()) {
3952
3916
  throw path.buildCodeFrameError(shared.messages.ONLY_TOP_LEVEL, SyntaxError);
3953
3917
  }
3954
3918
  if (path.node.arguments.length !== 1) {
@@ -3959,7 +3923,7 @@ function validateStyleXCreate(path) {
3959
3923
  }
3960
3924
  }
3961
3925
  function findNearestStatementAncestor(path) {
3962
- if (isStatement(path)) {
3926
+ if (path.isStatement()) {
3963
3927
  return path;
3964
3928
  }
3965
3929
  if (path.parentPath == null) {
@@ -3999,7 +3963,7 @@ function transformStyleXDefineVars(callExpressionPath, state) {
3999
3963
  if (callExpressionNode.callee.type === 'Identifier' && state.stylexDefineVarsImport.has(callExpressionNode.callee.name) || callExpressionNode.callee.type === 'MemberExpression' && callExpressionNode.callee.property.name === 'defineVars' && callExpressionNode.callee.object.type === 'Identifier' && callExpressionNode.callee.property.type === 'Identifier' && state.stylexImport.has(callExpressionNode.callee.object.name)) {
4000
3964
  validateStyleXDefineVars(callExpressionPath);
4001
3965
  const variableDeclaratorPath = callExpressionPath.parentPath;
4002
- if (!isVariableDeclarator(variableDeclaratorPath)) {
3966
+ if (!variableDeclaratorPath.isVariableDeclarator()) {
4003
3967
  return;
4004
3968
  }
4005
3969
  const variableDeclaratorNode = variableDeclaratorPath.node;
@@ -4099,11 +4063,11 @@ function transformStyleXCreateTheme(callExpressionPath, state) {
4099
4063
  if (callExpressionNode.callee.type === 'Identifier' && state.stylexCreateThemeImport.has(callExpressionNode.callee.name) || callExpressionNode.callee.type === 'MemberExpression' && callExpressionNode.callee.object.type === 'Identifier' && callExpressionNode.callee.property.type === 'Identifier' && callExpressionNode.callee.property.name === 'createTheme' && state.stylexImport.has(callExpressionNode.callee.object.name)) {
4100
4064
  validateStyleXCreateTheme(callExpressionPath);
4101
4065
  const variableDeclaratorPath = callExpressionPath.parentPath;
4102
- if (!isVariableDeclarator(variableDeclaratorPath)) {
4066
+ if (!variableDeclaratorPath.isVariableDeclarator()) {
4103
4067
  return;
4104
4068
  }
4105
4069
  const id = variableDeclaratorPath.get('id');
4106
- if (!isIdentifier(id)) {
4070
+ if (!id.isIdentifier()) {
4107
4071
  return;
4108
4072
  }
4109
4073
  const variableName = id.node.name;
@@ -4222,7 +4186,7 @@ function transformStyleXKeyframes(path, state) {
4222
4186
  throw path.buildCodeFrameError(shared.messages.NON_OBJECT_FOR_STYLEX_KEYFRAMES_CALL, SyntaxError);
4223
4187
  }
4224
4188
  const init = path.get('init');
4225
- if (init == null || !isCallExpression(init)) {
4189
+ if (init == null || !init.isCallExpression()) {
4226
4190
  throw path.buildCodeFrameError(shared.messages.NON_STATIC_KEYFRAME_VALUE, SyntaxError);
4227
4191
  }
4228
4192
  const args = init.get('arguments');
@@ -4414,7 +4378,7 @@ function transformStyleXMerge(path, state) {
4414
4378
  state.styleVarsToKeep.add([objName, propName != null ? String(propName) : true, styleNonNullProps]);
4415
4379
  }
4416
4380
  }
4417
- if (isMemberExpression(argPath)) {
4381
+ if (argPath.isMemberExpression()) {
4418
4382
  MemberExpression(argPath);
4419
4383
  } else {
4420
4384
  argPath.traverse({
@@ -4460,7 +4424,7 @@ function parseNullableStyle$2(node, state) {
4460
4424
  function makeStringExpression$2(values) {
4461
4425
  const conditions = values.filter(v => Array.isArray(v)).map(v => v[0]);
4462
4426
  if (conditions.length === 0) {
4463
- return t__namespace.stringLiteral(stylex(...values));
4427
+ return t__namespace.stringLiteral(stylex.legacyMerge(...values));
4464
4428
  }
4465
4429
  const conditionPermutations = genConditionPermutations$2(conditions.length);
4466
4430
  const objEntries = conditionPermutations.map(permutation => {
@@ -4474,7 +4438,7 @@ function makeStringExpression$2(values) {
4474
4438
  }
4475
4439
  });
4476
4440
  const key = permutation.reduce((soFar, bool) => soFar << 1 | (bool ? 1 : 0), 0);
4477
- return t__namespace.objectProperty(t__namespace.numericLiteral(key), t__namespace.stringLiteral(stylex(...args)));
4441
+ return t__namespace.objectProperty(t__namespace.numericLiteral(key), t__namespace.stringLiteral(stylex.legacyMerge(...args)));
4478
4442
  });
4479
4443
  const objExpressions = t__namespace.objectExpression(objEntries);
4480
4444
  const conditionsToKey = genBitwiseOrOfConditions$2(conditions);
@@ -4636,7 +4600,7 @@ function transformStylexProps(path, state) {
4636
4600
  state.styleVarsToKeep.add([objName, propName != null ? String(propName) : true, styleNonNullProps]);
4637
4601
  }
4638
4602
  }
4639
- if (isMemberExpression(argPath)) {
4603
+ if (argPath.isMemberExpression()) {
4640
4604
  MemberExpression(argPath);
4641
4605
  } else {
4642
4606
  argPath.traverse({
@@ -4871,7 +4835,7 @@ function transformStylexAttrs(path, state) {
4871
4835
  state.styleVarsToKeep.add([objName, propName != null ? String(propName) : true, styleNonNullProps]);
4872
4836
  }
4873
4837
  }
4874
- if (isMemberExpression(argPath)) {
4838
+ if (argPath.isMemberExpression()) {
4875
4839
  MemberExpression(argPath);
4876
4840
  } else {
4877
4841
  argPath.traverse({
@@ -4981,10 +4945,10 @@ function styleXTransform() {
4981
4945
  enter: (path, s) => {
4982
4946
  state = new StateManager(s);
4983
4947
  for (const block of path.get('body')) {
4984
- if (isImportDeclaration(block)) {
4948
+ if (block.isImportDeclaration()) {
4985
4949
  readImportDeclarations(block, state);
4986
4950
  }
4987
- if (isVariableDeclaration(block)) {
4951
+ if (block.isVariableDeclaration()) {
4988
4952
  for (const decl of block.get('declarations')) {
4989
4953
  readRequires(decl, state);
4990
4954
  }
@@ -4993,14 +4957,36 @@ function styleXTransform() {
4993
4957
  },
4994
4958
  exit: path => {
4995
4959
  path.traverse({
4960
+ ImportDeclaration(path) {
4961
+ const filename = state.filename;
4962
+ if (filename == null || !state.options.rewriteAliases) {
4963
+ return;
4964
+ }
4965
+ const source = path.node.source.value;
4966
+ const aliases = state.options.aliases;
4967
+ const themeFileExtension = '.stylex';
4968
+ if (!matchesFileSuffix(themeFileExtension)(source)) {
4969
+ return;
4970
+ }
4971
+ const resolvedFilePath = filePathResolver(source, filename, aliases);
4972
+ if (resolvedFilePath == null) {
4973
+ return;
4974
+ }
4975
+ let relativeFilePath = getRelativePath(filename, resolvedFilePath);
4976
+ const extension = EXTENSIONS.find(ext => relativeFilePath.endsWith(ext));
4977
+ if (extension != null) {
4978
+ relativeFilePath = relativeFilePath.slice(0, -extension.length);
4979
+ }
4980
+ path.node.source.value = relativeFilePath;
4981
+ },
4996
4982
  Identifier(path) {
4997
- if (isReferencedIdentifier(path)) {
4983
+ if (path.isReferencedIdentifier()) {
4998
4984
  const {
4999
4985
  name
5000
4986
  } = path.node;
5001
4987
  if (state.styleMap.has(name)) {
5002
4988
  const parentPath = path.parentPath;
5003
- if (isMemberExpression(parentPath)) {
4989
+ if (parentPath.isMemberExpression()) {
5004
4990
  const {
5005
4991
  property,
5006
4992
  computed
@@ -5064,11 +5050,11 @@ function styleXTransform() {
5064
5050
  path.remove();
5065
5051
  return;
5066
5052
  }
5067
- if (isVariableDeclarator(path)) {
5053
+ if (path.isVariableDeclarator()) {
5068
5054
  const init = path.get('init');
5069
- if (init != null && isObjectExpression(init)) {
5055
+ if (init != null && init.isObjectExpression()) {
5070
5056
  for (const prop of init.get('properties')) {
5071
- if (isObjectProperty(prop)) {
5057
+ if (prop.isObjectProperty()) {
5072
5058
  const key = prop.get('key').node;
5073
5059
  const keyAsString = key.type === 'Identifier' ? key.name : key.type === 'StringLiteral' ? key.value : key.type === 'NumericLiteral' ? String(key.value) : null;
5074
5060
  if (keyAsString != null) {
@@ -5085,9 +5071,9 @@ function styleXTransform() {
5085
5071
  if (!allNullsToKeep.includes(true)) {
5086
5072
  const nullsToKeep = new Set(allNullsToKeep.filter(x => x !== true).flat());
5087
5073
  const styleObject = prop.get('value');
5088
- if (isObjectExpression(styleObject)) {
5074
+ if (styleObject.isObjectExpression()) {
5089
5075
  for (const styleProp of styleObject.get('properties')) {
5090
- if (isObjectProperty(styleProp) && isNullLiteral(styleProp.get('value'))) {
5076
+ if (styleProp.isObjectProperty() && styleProp.get('value').isNullLiteral()) {
5091
5077
  const styleKey = styleProp.get('key').node;
5092
5078
  const styleKeyAsString = styleKey.type === 'Identifier' ? styleKey.name : styleKey.type === 'StringLiteral' ? styleKey.value : styleKey.type === 'NumericLiteral' ? String(styleKey.value) : null;
5093
5079
  if (styleKeyAsString != null && !nullsToKeep.has(styleKeyAsString)) {
@@ -5110,7 +5096,7 @@ function styleXTransform() {
5110
5096
  }
5111
5097
  },
5112
5098
  CallExpression(path) {
5113
- if (isVariableDeclarator(path.parentPath)) {
5099
+ if (path.parentPath.isVariableDeclarator()) {
5114
5100
  transformStyleXKeyframes(path.parentPath, state);
5115
5101
  }
5116
5102
  transformStyleXDefineVars(path, state);
@@ -5125,10 +5111,10 @@ function stylexPluginWithOptions(options) {
5125
5111
  }
5126
5112
  styleXTransform.withOptions = stylexPluginWithOptions;
5127
5113
  function isExported(path) {
5128
- if (path == null || isProgram(path)) {
5114
+ if (path == null || path.isProgram()) {
5129
5115
  return false;
5130
5116
  }
5131
- if (isExportNamedDeclaration(path) || isExportDefaultDeclaration(path)) {
5117
+ if (path.isExportNamedDeclaration() || path.isExportDefaultDeclaration()) {
5132
5118
  return true;
5133
5119
  }
5134
5120
  return isExported(path.parentPath);