@plumeria/turbopack-loader 16.2.5 → 16.2.7

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 +41 -19
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -104,6 +104,24 @@ async function loader(source) {
104
104
  }
105
105
  }
106
106
  const scannedTables = (0, utils_1.scanAll)();
107
+ if (scannedTables.componentPropsTable) {
108
+ const parentFiles = new Set();
109
+ for (const compKey of Object.keys(scannedTables.componentPropsTable)) {
110
+ if (!compKey.startsWith(`${resourcePath}-`))
111
+ continue;
112
+ const props = scannedTables.componentPropsTable[compKey];
113
+ for (const propName of Object.keys(props)) {
114
+ for (const entry of props[propName]) {
115
+ if (entry.filePath !== resourcePath) {
116
+ parentFiles.add(entry.filePath);
117
+ }
118
+ }
119
+ }
120
+ }
121
+ for (const parentFile of parentFiles) {
122
+ this.addDependency(parentFile);
123
+ }
124
+ }
107
125
  const extractedSheets = [];
108
126
  const addSheet = (sheet) => {
109
127
  if (!extractedSheets.includes(sheet)) {
@@ -837,7 +855,7 @@ async function loader(source) {
837
855
  const currentGroupId = ++groupIdCounter;
838
856
  const uniqueEntries = [];
839
857
  propPossibilities.forEach((entry) => {
840
- if (!uniqueEntries.some((x) => x.index === entry.index)) {
858
+ if (!uniqueEntries.some((x) => x.key === entry.key)) {
841
859
  uniqueEntries.push(entry);
842
860
  }
843
861
  });
@@ -845,12 +863,12 @@ async function loader(source) {
845
863
  conditionals.push({
846
864
  test: expr,
847
865
  testLHS,
848
- testString: `${testLHS} === ${entry.index}`,
866
+ testString: `${testLHS} === ${JSON.stringify(entry.key)}`,
849
867
  truthy: entry.styleObj,
850
868
  falsy: {},
851
869
  groupId: currentGroupId,
852
870
  groupName: undefined,
853
- valueName: String(entry.index),
871
+ valueName: entry.key,
854
872
  varName,
855
873
  });
856
874
  });
@@ -1450,6 +1468,10 @@ async function loader(source) {
1450
1468
  const imported = localImports[parentTagName];
1451
1469
  if (imported) {
1452
1470
  compKey = `${imported.actualPath}-${imported.importedName}`;
1471
+ const resolved = (0, utils_1.resolveExport)(imported.actualPath, imported.importedName);
1472
+ if (resolved) {
1473
+ compKey = `${resolved.filePath}-${resolved.localName}`;
1474
+ }
1453
1475
  }
1454
1476
  else {
1455
1477
  compKey = `${resourcePath}-${parentTagName}`;
@@ -1459,28 +1481,28 @@ async function loader(source) {
1459
1481
  node.value &&
1460
1482
  node.value.type === 'JSXExpressionContainer') {
1461
1483
  const expr = node.value.expression;
1484
+ const replaceWithKey = (subNode) => {
1485
+ const entry = list.find((x) => x.spanStart === subNode.span.start &&
1486
+ x.filePath === resourcePath);
1487
+ if (entry) {
1488
+ replacements.push({
1489
+ start: subNode.span.start - baseByteOffset,
1490
+ end: subNode.span.end - baseByteOffset,
1491
+ content: JSON.stringify(entry.key),
1492
+ });
1493
+ processStyleRecords(entry.styleObj);
1494
+ return true;
1495
+ }
1496
+ return false;
1497
+ };
1462
1498
  (0, utils_1.traverse)(expr, {
1463
1499
  MemberExpression({ node: subNode }) {
1464
- const entry = list.find((x) => x.spanStart === subNode.span.start &&
1465
- x.filePath === resourcePath);
1466
- if (entry) {
1467
- replacements.push({
1468
- start: subNode.span.start - baseByteOffset,
1469
- end: subNode.span.end - baseByteOffset,
1470
- content: String(entry.index),
1471
- });
1500
+ if (replaceWithKey(subNode)) {
1472
1501
  excludeSubtreeSpans(subNode);
1473
1502
  }
1474
1503
  },
1475
1504
  ArrayExpression({ node: subNode }) {
1476
- const entry = list.find((x) => x.spanStart === subNode.span.start &&
1477
- x.filePath === resourcePath);
1478
- if (entry) {
1479
- replacements.push({
1480
- start: subNode.span.start - baseByteOffset,
1481
- end: subNode.span.end - baseByteOffset,
1482
- content: String(entry.index),
1483
- });
1505
+ if (replaceWithKey(subNode)) {
1484
1506
  excludeSubtreeSpans(subNode);
1485
1507
  }
1486
1508
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/turbopack-loader",
3
- "version": "16.2.5",
3
+ "version": "16.2.7",
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": "^16.2.5"
25
+ "@plumeria/utils": "^16.2.7"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@swc/core": "1.15.43",