@plumeria/turbopack-loader 7.0.2 → 7.1.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.
Files changed (2) hide show
  1. package/dist/index.js +433 -114
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -269,11 +269,15 @@ async function loader(source) {
269
269
  }
270
270
  return undefined;
271
271
  });
272
+ const { hashMap, sheets } = (0, utils_1.processVariants)(obj);
273
+ if (!isProduction) {
274
+ sheets.forEach(addSheet);
275
+ }
272
276
  localCreateStyles[node.id.value] = {
273
277
  name: node.id.value,
274
278
  type: 'variant',
275
279
  obj,
276
- hashMap: {},
280
+ hashMap,
277
281
  isExported,
278
282
  initSpan: {
279
283
  start: node.init.span.start - ast.span.start,
@@ -492,11 +496,63 @@ async function loader(source) {
492
496
  return;
493
497
  const styleInfo = localCreateStyles[node.value];
494
498
  if (styleInfo) {
495
- replacements.push({
496
- start: node.span.start - ast.span.start,
497
- end: node.span.end - ast.span.start,
498
- content: JSON.stringify(styleInfo.hashMap),
499
- });
499
+ if (styleInfo.type === 'variant') {
500
+ const hashMap = styleInfo.hashMap;
501
+ const independentKeys = Object.keys(hashMap).filter((k) => k !== '_compound');
502
+ const compoundGroups = hashMap._compound || [];
503
+ const independentChecks = independentKeys
504
+ .map((key) => {
505
+ const mapObj = hashMap[key];
506
+ if (typeof mapObj === 'string') {
507
+ return `classes.push("${mapObj}");`;
508
+ }
509
+ const mapStr = JSON.stringify(mapObj);
510
+ return `
511
+ var v${key} = ${mapStr};
512
+ if (props["${key}"] && v${key}[props["${key}"]]) {
513
+ classes.push(v${key}[props["${key}"]]);
514
+ } else if (v${key}["default"]) {
515
+ classes.push(v${key}["default"]);
516
+ }
517
+ `;
518
+ })
519
+ .join('\n');
520
+ const compoundChecks = compoundGroups
521
+ .map((group) => {
522
+ const keys = group.keys;
523
+ const mapObj = group.map;
524
+ const mapStr = JSON.stringify(mapObj);
525
+ const keyExpr = keys
526
+ .map((k) => `(props["${k}"] || "default")`)
527
+ .join(' + ":" + ');
528
+ return `
529
+ var c${keys.join('_')} = ${mapStr};
530
+ var k = ${keyExpr};
531
+ if (c${keys.join('_')}[k]) {
532
+ classes.push(c${keys.join('_')}[k]);
533
+ }
534
+ `;
535
+ })
536
+ .join('\n');
537
+ const runtimeFn = `(props) => {
538
+ var classes = [];
539
+ ${independentChecks}
540
+ ${compoundChecks}
541
+ return classes.join(" ");
542
+ }`;
543
+ replacements.push({
544
+ start: node.span.start - ast.span.start,
545
+ end: node.span.end - ast.span.start,
546
+ content: runtimeFn,
547
+ });
548
+ }
549
+ else {
550
+ replacements.push({
551
+ start: node.span.start - ast.span.start,
552
+ end: node.span.end - ast.span.start,
553
+ content: JSON.stringify(styleInfo.hashMap),
554
+ });
555
+ }
500
556
  return;
501
557
  }
502
558
  const varName = node.value;
@@ -690,10 +746,14 @@ async function loader(source) {
690
746
  Object.entries(groupVariants).forEach(([optionName, style]) => {
691
747
  conditionals.push({
692
748
  test: valExpr,
749
+ testLHS: valSource,
693
750
  testString: `${valSource} === '${optionName}'`,
694
751
  truthy: style,
695
752
  falsy: {},
696
753
  groupId: currentGroupId,
754
+ groupName,
755
+ valueName: optionName,
756
+ varName,
697
757
  });
698
758
  });
699
759
  }
@@ -713,10 +773,14 @@ async function loader(source) {
713
773
  Object.entries(variantObj).forEach(([key, style]) => {
714
774
  conditionals.push({
715
775
  test: arg,
776
+ testLHS: argSource,
716
777
  testString: `${argSource} === '${key}'`,
717
778
  truthy: style,
718
779
  falsy: {},
719
780
  groupId: currentGroupId,
781
+ groupName: undefined,
782
+ valueName: key,
783
+ varName,
720
784
  });
721
785
  });
722
786
  continue;
@@ -725,43 +789,111 @@ async function loader(source) {
725
789
  break;
726
790
  }
727
791
  }
728
- const staticStyle = resolveStyleObject(expr);
729
- if (staticStyle) {
730
- baseStyle = (0, utils_1.deepMerge)(baseStyle, staticStyle);
731
- continue;
732
- }
733
- else if (expr.type === 'ConditionalExpression') {
734
- const truthyStyle = resolveStyleObject(expr.consequent);
735
- const falsyStyle = resolveStyleObject(expr.alternate);
736
- if (truthyStyle !== null && falsyStyle !== null) {
737
- conditionals.push({
738
- test: expr.test,
739
- truthy: truthyStyle,
740
- falsy: falsyStyle,
741
- });
742
- continue;
792
+ else if (utils_1.t.isIdentifier(expr)) {
793
+ const varName = expr.value;
794
+ let variantObj;
795
+ const uniqueKey = `${this.resourcePath}-${varName}`;
796
+ let hash = scannedTables.variantsHashTable[uniqueKey];
797
+ if (!hash) {
798
+ hash = mergedVariantsTable[varName];
743
799
  }
744
- }
745
- else if (expr.type === 'BinaryExpression' &&
746
- expr.operator === '&&') {
747
- const truthyStyle = resolveStyleObject(expr.right);
748
- if (truthyStyle !== null) {
749
- conditionals.push({
750
- test: expr.left,
751
- truthy: truthyStyle,
752
- falsy: {},
800
+ if (hash && scannedTables.variantsObjectTable[hash]) {
801
+ variantObj = scannedTables.variantsObjectTable[hash];
802
+ }
803
+ if (!variantObj) {
804
+ if (localCreateStyles[varName] &&
805
+ localCreateStyles[varName].obj) {
806
+ variantObj = localCreateStyles[varName].obj;
807
+ }
808
+ }
809
+ if (variantObj) {
810
+ Object.entries(variantObj).forEach(([groupName, groupVariants]) => {
811
+ if (!groupVariants)
812
+ return;
813
+ const currentGroupId = ++groupIdCounter;
814
+ Object.entries(groupVariants).forEach(([optionName, style]) => {
815
+ conditionals.push({
816
+ test: expr,
817
+ testLHS: `props["${groupName}"]`,
818
+ testString: `props["${groupName}"] === '${optionName}'`,
819
+ truthy: style,
820
+ falsy: {},
821
+ groupId: currentGroupId,
822
+ groupName: groupName,
823
+ valueName: optionName,
824
+ varName: varName,
825
+ });
826
+ });
753
827
  });
754
828
  continue;
755
829
  }
756
830
  }
757
- else if (expr.type === 'ParenthesisExpression') {
758
- const inner = expr.expression;
759
- const innerStatic = resolveStyleObject(inner);
760
- if (innerStatic) {
761
- baseStyle = (0, utils_1.deepMerge)(baseStyle, innerStatic);
762
- continue;
831
+ const getSource = (node) => {
832
+ const start = node.span.start - ast.span.start;
833
+ const end = node.span.end - ast.span.start;
834
+ return source.substring(start, end);
835
+ };
836
+ const collectConditions = (node, currentTestStrings = []) => {
837
+ const staticStyle = resolveStyleObject(node);
838
+ if (staticStyle) {
839
+ if (currentTestStrings.length === 0) {
840
+ baseStyle = (0, utils_1.deepMerge)(baseStyle, staticStyle);
841
+ }
842
+ else {
843
+ const combinedTest = currentTestStrings.join(' && ');
844
+ conditionals.push({
845
+ test: node,
846
+ testString: combinedTest,
847
+ truthy: staticStyle,
848
+ falsy: {},
849
+ varName: undefined,
850
+ });
851
+ }
852
+ return true;
763
853
  }
764
- }
854
+ if (node.type === 'ConditionalExpression') {
855
+ const testSource = getSource(node.test);
856
+ if (currentTestStrings.length === 0) {
857
+ const trueStyle = resolveStyleObject(node.consequent);
858
+ const falseStyle = resolveStyleObject(node.alternate);
859
+ if (trueStyle && falseStyle) {
860
+ conditionals.push({
861
+ test: node,
862
+ testString: testSource,
863
+ truthy: trueStyle,
864
+ falsy: falseStyle,
865
+ varName: undefined,
866
+ });
867
+ return true;
868
+ }
869
+ }
870
+ collectConditions(node.consequent, [
871
+ ...currentTestStrings,
872
+ `(${testSource})`,
873
+ ]);
874
+ collectConditions(node.alternate, [
875
+ ...currentTestStrings,
876
+ `!(${testSource})`,
877
+ ]);
878
+ return true;
879
+ }
880
+ else if (node.type === 'BinaryExpression' &&
881
+ node.operator === '&&') {
882
+ const leftSource = getSource(node.left);
883
+ collectConditions(node.right, [
884
+ ...currentTestStrings,
885
+ `(${leftSource})`,
886
+ ]);
887
+ return true;
888
+ }
889
+ else if (node.type === 'ParenthesisExpression') {
890
+ return collectConditions(node.expression, currentTestStrings);
891
+ }
892
+ return false;
893
+ };
894
+ const handled = collectConditions(expr);
895
+ if (handled)
896
+ continue;
765
897
  isOptimizable = false;
766
898
  break;
767
899
  }
@@ -783,103 +915,290 @@ async function loader(source) {
783
915
  });
784
916
  }
785
917
  else {
786
- const table = {};
787
- const groups = {};
788
- let strayIdCounter = groupIdCounter + 1;
918
+ const propertyCounts = {};
919
+ const addCounts = (style) => {
920
+ Object.keys(style).forEach((key) => {
921
+ propertyCounts[key] = (propertyCounts[key] || 0) + 1;
922
+ });
923
+ };
924
+ addCounts(baseStyle);
925
+ const participation = {};
926
+ const registerParticipation = (style, sourceId) => {
927
+ Object.keys(style).forEach((key) => {
928
+ if (!participation[key])
929
+ participation[key] = new Set();
930
+ participation[key].add(sourceId);
931
+ });
932
+ };
933
+ registerParticipation(baseStyle, 'base');
934
+ conditionals
935
+ .filter((c) => c.groupId === undefined)
936
+ .forEach((c, idx) => {
937
+ const sourceId = `std_${idx}`;
938
+ registerParticipation(c.truthy, sourceId);
939
+ registerParticipation(c.falsy, sourceId);
940
+ });
941
+ const variantGroups = {};
789
942
  conditionals.forEach((c) => {
790
- const gid = c.groupId !== undefined ? c.groupId : strayIdCounter++;
791
- if (!groups[gid]) {
792
- groups[gid] = [];
943
+ if (c.groupId !== undefined) {
944
+ if (!variantGroups[c.groupId])
945
+ variantGroups[c.groupId] = [];
946
+ variantGroups[c.groupId].push(c);
947
+ }
948
+ });
949
+ Object.entries(variantGroups).forEach(([groupId, opts]) => {
950
+ const sourceId = `var_${groupId}`;
951
+ opts.forEach((opt) => {
952
+ registerParticipation(opt.truthy, sourceId);
953
+ registerParticipation(opt.falsy, sourceId);
954
+ });
955
+ });
956
+ const conflictingKeys = new Set();
957
+ Object.entries(participation).forEach(([key, sources]) => {
958
+ if (sources.size > 1) {
959
+ conflictingKeys.add(key);
793
960
  }
794
- groups[gid].push(c);
795
961
  });
796
- const sortedGroupIds = Object.keys(groups)
797
- .map(Number)
798
- .sort((a, b) => a - b);
799
- let totalCombinations = 1;
800
- const groupMeta = sortedGroupIds.map((gid) => {
801
- const options = groups[gid];
802
- const isVariantGroup = options[0].groupId !== undefined;
803
- const size = isVariantGroup ? options.length : 2;
804
- const stride = totalCombinations;
805
- totalCombinations *= size;
806
- return { gid, options, size, stride, isVariantGroup };
962
+ const baseIndependent = {};
963
+ const baseConflict = {};
964
+ Object.entries(baseStyle).forEach(([key, val]) => {
965
+ if (conflictingKeys.has(key)) {
966
+ baseConflict[key] = val;
967
+ }
968
+ else {
969
+ baseIndependent[key] = val;
970
+ }
807
971
  });
808
- for (let i = 0; i < totalCombinations; i++) {
809
- let currentStyle = { ...baseStyle };
810
- for (const meta of groupMeta) {
811
- const localIndex = Math.floor(i / meta.stride) % meta.size;
812
- if (meta.isVariantGroup) {
813
- currentStyle = (0, utils_1.deepMerge)(currentStyle, meta.options[localIndex].truthy);
972
+ const indepConditionals = [];
973
+ const conflictConditionals = [];
974
+ const splitConditional = (c) => {
975
+ const truthyIndep = {};
976
+ const truthyConf = {};
977
+ const falsyIndep = {};
978
+ const falsyConf = {};
979
+ let hasIndep = false;
980
+ let hasConf = false;
981
+ Object.entries(c.truthy).forEach(([k, v]) => {
982
+ if (conflictingKeys.has(k)) {
983
+ truthyConf[k] = v;
984
+ hasConf = true;
814
985
  }
815
986
  else {
816
- const cond = meta.options[0];
817
- if (localIndex === 1) {
818
- currentStyle = (0, utils_1.deepMerge)(currentStyle, cond.truthy);
819
- }
820
- else {
821
- currentStyle = (0, utils_1.deepMerge)(currentStyle, cond.falsy);
822
- }
987
+ truthyIndep[k] = v;
988
+ hasIndep = true;
989
+ }
990
+ });
991
+ Object.entries(c.falsy).forEach(([k, v]) => {
992
+ if (conflictingKeys.has(k)) {
993
+ falsyConf[k] = v;
994
+ hasConf = true;
823
995
  }
996
+ else {
997
+ falsyIndep[k] = v;
998
+ hasIndep = true;
999
+ }
1000
+ });
1001
+ if (hasIndep) {
1002
+ indepConditionals.push({
1003
+ ...c,
1004
+ truthy: truthyIndep,
1005
+ falsy: falsyIndep,
1006
+ });
1007
+ }
1008
+ if (hasConf) {
1009
+ conflictConditionals.push({
1010
+ ...c,
1011
+ truthy: truthyConf,
1012
+ falsy: falsyConf,
1013
+ });
1014
+ }
1015
+ };
1016
+ conditionals.forEach(splitConditional);
1017
+ const classParts = [];
1018
+ if (Object.keys(baseIndependent).length > 0) {
1019
+ if (!isProduction) {
1020
+ (0, utils_1.extractOndemandStyles)(baseIndependent, extractedSheets, scannedTables);
1021
+ }
1022
+ const records = (0, utils_1.getStyleRecords)(baseIndependent);
1023
+ if (!isProduction) {
1024
+ records.forEach((r) => addSheet(r.sheet));
824
1025
  }
825
- if (process.env.NODE_ENV !== 'production') {
826
- (0, utils_1.extractOndemandStyles)(currentStyle, extractedSheets, scannedTables);
1026
+ const className = records.map((r) => r.hash).join(' ');
1027
+ if (className)
1028
+ classParts.push(JSON.stringify(className));
1029
+ }
1030
+ const indepStd = indepConditionals.filter((c) => c.groupId === undefined);
1031
+ indepStd.forEach((c) => {
1032
+ const processBranch = (style) => {
1033
+ if (Object.keys(style).length === 0)
1034
+ return '""';
1035
+ if (!isProduction)
1036
+ (0, utils_1.extractOndemandStyles)(style, extractedSheets, scannedTables);
1037
+ const records = (0, utils_1.getStyleRecords)(style);
1038
+ if (!isProduction)
1039
+ records.forEach((r) => addSheet(r.sheet));
1040
+ return JSON.stringify(records.map((r) => r.hash).join(' '));
1041
+ };
1042
+ const tClass = processBranch(c.truthy);
1043
+ const fClass = processBranch(c.falsy);
1044
+ let testStr = c.testString;
1045
+ if (!testStr && c.test) {
1046
+ const start = c.test.span.start - ast.span.start;
1047
+ const end = c.test.span.end - ast.span.start;
1048
+ testStr = source.substring(start, end);
1049
+ }
1050
+ classParts.push(`(${testStr} ? ${tClass} : ${fClass})`);
1051
+ });
1052
+ const indepVarGroups = {};
1053
+ indepConditionals.forEach((c) => {
1054
+ if (c.groupId !== undefined) {
1055
+ if (!indepVarGroups[c.groupId])
1056
+ indepVarGroups[c.groupId] = [];
1057
+ indepVarGroups[c.groupId].push(c);
1058
+ }
1059
+ });
1060
+ Object.values(indepVarGroups).forEach((options) => {
1061
+ let commonTestExpr = null;
1062
+ const lookupMap = {};
1063
+ if (options.length > 0) {
1064
+ if (options[0].testLHS) {
1065
+ commonTestExpr = options[0].testLHS;
1066
+ }
1067
+ else if (options[0].testString) {
1068
+ commonTestExpr = options[0].testString;
1069
+ }
1070
+ else {
1071
+ const firstTest = options[0].test;
1072
+ const firstStart = firstTest.span.start - ast.span.start;
1073
+ const firstEnd = firstTest.span.end - ast.span.start;
1074
+ commonTestExpr = source.substring(firstStart, firstEnd);
1075
+ }
1076
+ options.forEach((opt) => {
1077
+ if (opt.valueName && opt.truthy) {
1078
+ if (!isProduction)
1079
+ (0, utils_1.extractOndemandStyles)(opt.truthy, extractedSheets, scannedTables);
1080
+ const records = (0, utils_1.getStyleRecords)(opt.truthy);
1081
+ if (!isProduction)
1082
+ records.forEach((r) => addSheet(r.sheet));
1083
+ const className = records.map((r) => r.hash).join(' ');
1084
+ if (className) {
1085
+ lookupMap[opt.valueName] = className;
1086
+ }
1087
+ }
1088
+ });
827
1089
  }
828
- const records = (0, utils_1.getStyleRecords)(currentStyle);
829
- if (process.env.NODE_ENV !== 'production') {
830
- records.forEach((r) => extractedSheets.push(r.sheet));
1090
+ if (commonTestExpr && Object.keys(lookupMap).length > 0) {
1091
+ const entries = Object.entries(lookupMap)
1092
+ .map(([key, val]) => `"${key}":"${val}"`)
1093
+ .join(',');
1094
+ classParts.push(`({${entries}}[${commonTestExpr}] || "")`);
831
1095
  }
832
- const className = records
833
- .map((r) => r.hash)
834
- .join(' ');
835
- table[i] = className;
836
- }
837
- const indexParts = [];
838
- for (const meta of groupMeta) {
839
- if (meta.isVariantGroup) {
840
- const exprs = meta.options
841
- .map((opt, idx) => {
842
- if (idx === 0)
843
- return null;
844
- let testStr = opt.testString;
845
- if (!testStr && opt.test) {
846
- const start = opt.test.span.start - ast.span.start;
847
- const end = opt.test.span.end - ast.span.start;
848
- testStr = source.substring(start, end);
1096
+ });
1097
+ if (Object.keys(baseConflict).length > 0 ||
1098
+ conflictConditionals.length > 0) {
1099
+ const conflictStd = conflictConditionals.filter((c) => c.groupId === undefined);
1100
+ const conflictVarGroups = {};
1101
+ conflictConditionals.forEach((c) => {
1102
+ if (c.groupId !== undefined) {
1103
+ if (!conflictVarGroups[c.groupId])
1104
+ conflictVarGroups[c.groupId] = [];
1105
+ conflictVarGroups[c.groupId].push(c);
1106
+ }
1107
+ });
1108
+ const dimensions = [];
1109
+ conflictStd.forEach((c) => {
1110
+ let testStr = c.testString;
1111
+ if (!testStr && c.test) {
1112
+ const start = c.test.span.start - ast.span.start;
1113
+ const end = c.test.span.end - ast.span.start;
1114
+ testStr = source.substring(start, end);
1115
+ }
1116
+ dimensions.push({
1117
+ type: 'std',
1118
+ testExpr: testStr,
1119
+ options: [
1120
+ { value: 0, style: c.falsy, label: 'false' },
1121
+ { value: 1, style: c.truthy, label: 'true' },
1122
+ ],
1123
+ });
1124
+ });
1125
+ Object.entries(conflictVarGroups).forEach(([_groupId, opts]) => {
1126
+ let commonTestExpr = null;
1127
+ if (opts.length > 0) {
1128
+ if (opts[0].testLHS) {
1129
+ commonTestExpr = opts[0].testLHS;
849
1130
  }
850
- return `(!!(${testStr}) * ${idx})`;
851
- })
852
- .filter(Boolean);
853
- if (exprs.length > 0) {
854
- const groupSum = `(${exprs.join(' + ')})`;
855
- if (meta.stride > 1) {
856
- indexParts.push(`(${groupSum} * ${meta.stride})`);
1131
+ else if (opts[0].testString) {
1132
+ commonTestExpr = opts[0].testString;
857
1133
  }
858
1134
  else {
859
- indexParts.push(groupSum);
1135
+ const firstTest = opts[0].test;
1136
+ const firstStart = firstTest.span.start - ast.span.start;
1137
+ const firstEnd = firstTest.span.end - ast.span.start;
1138
+ commonTestExpr = source.substring(firstStart, firstEnd);
860
1139
  }
861
1140
  }
862
- }
863
- else {
864
- const cond = meta.options[0];
865
- let testStr = cond.testString;
866
- if (!testStr && cond.test) {
867
- const start = cond.test.span.start - ast.span.start;
868
- const end = cond.test.span.end - ast.span.start;
869
- testStr = source.substring(start, end);
1141
+ const options = opts.map((opt) => ({
1142
+ value: opt.valueName,
1143
+ style: opt.truthy,
1144
+ label: opt.valueName || 'default',
1145
+ }));
1146
+ dimensions.push({
1147
+ type: 'var',
1148
+ testExpr: commonTestExpr || '""',
1149
+ options: options,
1150
+ });
1151
+ });
1152
+ const results = {};
1153
+ const recurse = (dimIndex, currentStyle, keyParts) => {
1154
+ if (dimIndex >= dimensions.length) {
1155
+ if (!isProduction)
1156
+ (0, utils_1.extractOndemandStyles)(currentStyle, extractedSheets, scannedTables);
1157
+ const records = (0, utils_1.getStyleRecords)(currentStyle);
1158
+ if (!isProduction)
1159
+ records.forEach((r) => addSheet(r.sheet));
1160
+ const className = records.map((r) => r.hash).join(' ');
1161
+ const finalKey = keyParts.join('__');
1162
+ if (className)
1163
+ results[finalKey] = className;
1164
+ return;
870
1165
  }
871
- const expr = `(!!(${testStr}))`;
872
- if (meta.stride > 1) {
873
- indexParts.push(`(${expr} * ${meta.stride})`);
1166
+ const dim = dimensions[dimIndex];
1167
+ dim.options.forEach((opt) => {
1168
+ const nextStyle = (0, utils_1.deepMerge)(currentStyle, opt.style);
1169
+ recurse(dimIndex + 1, nextStyle, [
1170
+ ...keyParts,
1171
+ String(opt.value),
1172
+ ]);
1173
+ });
1174
+ };
1175
+ recurse(0, baseConflict, []);
1176
+ let baseConflictClass = '';
1177
+ if (Object.keys(baseConflict).length > 0) {
1178
+ if (!isProduction)
1179
+ (0, utils_1.extractOndemandStyles)(baseConflict, extractedSheets, scannedTables);
1180
+ const records = (0, utils_1.getStyleRecords)(baseConflict);
1181
+ if (!isProduction)
1182
+ records.forEach((r) => addSheet(r.sheet));
1183
+ baseConflictClass = records.map((r) => r.hash).join(' ');
1184
+ }
1185
+ const keyExprs = [];
1186
+ dimensions.forEach((dim) => {
1187
+ if (dim.type === 'std') {
1188
+ keyExprs.push(`(${dim.testExpr} ? "1" : "0")`);
874
1189
  }
875
1190
  else {
876
- indexParts.push(`(${expr} * 1)`);
1191
+ keyExprs.push(dim.testExpr || '""');
877
1192
  }
878
- }
1193
+ });
1194
+ const masterKeyExpr = keyExprs.length > 0 ? keyExprs.join(' + "__" + ') : '""';
1195
+ const tableJson = JSON.stringify(results);
1196
+ const fallback = baseConflictClass
1197
+ ? JSON.stringify(baseConflictClass)
1198
+ : '""';
1199
+ classParts.push(`(${tableJson}[${masterKeyExpr}] || ${fallback})`);
879
1200
  }
880
- const indexExpr = indexParts.join(' + ') || '0';
881
- const tableStr = JSON.stringify(table);
882
- const replacement = `${tableStr}[${indexExpr}]`;
1201
+ const replacement = classParts.length > 0 ? classParts.join(' + " " + ') : '""';
883
1202
  replacements.push({
884
1203
  start: node.span.start - ast.span.start,
885
1204
  end: node.span.end - ast.span.start,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/turbopack-loader",
3
- "version": "7.0.2",
3
+ "version": "7.1.0",
4
4
  "description": "Plumeria Turbopack-loader",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",
@@ -22,7 +22,7 @@
22
22
  "zero-virtual.css"
23
23
  ],
24
24
  "dependencies": {
25
- "@plumeria/utils": "^7.0.2"
25
+ "@plumeria/utils": "^7.1.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@swc/core": "1.15.8",