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