@plumeria/turbopack-loader 18.3.12 → 18.3.14

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 +36 -11
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -91,6 +91,18 @@ const unwrapExport = (node) => {
91
91
  const isFunctionNode = (node) => node?.type === 'FunctionDeclaration' ||
92
92
  node?.type === 'FunctionExpression' ||
93
93
  node?.type === 'ArrowFunctionExpression';
94
+ const componentFunctionOf = (node) => {
95
+ if (isFunctionNode(node))
96
+ return node;
97
+ if (node?.type === 'CallExpression') {
98
+ for (const arg of node.arguments ?? []) {
99
+ const fn = componentFunctionOf(arg.expression);
100
+ if (fn)
101
+ return fn;
102
+ }
103
+ }
104
+ return undefined;
105
+ };
94
106
  const isStaticArgValue = (node) => node.type === 'StringLiteral' ||
95
107
  node.type === 'NumericLiteral' ||
96
108
  node.type === 'BooleanLiteral' ||
@@ -322,13 +334,18 @@ async function loader(source) {
322
334
  node: statement,
323
335
  });
324
336
  }
337
+ else if (statement?.type === 'CallExpression') {
338
+ const fn = componentFunctionOf(statement);
339
+ if (fn)
340
+ components.push({ name: 'default', node: fn });
341
+ }
325
342
  else if (utils_1.t.isVariableDeclaration(statement)) {
326
343
  for (const decl of statement.declarations) {
327
- if (utils_1.t.isIdentifier(decl.id) &&
328
- (decl.init?.type === 'ArrowFunctionExpression' ||
329
- decl.init?.type === 'FunctionExpression')) {
330
- components.push({ name: decl.id.value, node: decl.init });
331
- }
344
+ if (!utils_1.t.isIdentifier(decl.id))
345
+ continue;
346
+ const fn = componentFunctionOf(decl.init);
347
+ if (fn)
348
+ components.push({ name: decl.id.value, node: fn });
332
349
  }
333
350
  }
334
351
  }
@@ -848,12 +865,18 @@ async function loader(source) {
848
865
  if (isFunctionNode(statement)) {
849
866
  addFirstParamName(statement);
850
867
  }
868
+ else if (statement?.type === 'CallExpression') {
869
+ const fn = componentFunctionOf(statement);
870
+ if (fn)
871
+ addFirstParamName(fn);
872
+ }
851
873
  else if (utils_1.t.isVariableDeclaration(statement)) {
852
874
  for (const decl of statement.declarations) {
853
875
  if (!utils_1.t.isIdentifier(decl.id) || !decl.init)
854
876
  continue;
855
- if (isFunctionNode(decl.init))
856
- addFirstParamName(decl.init);
877
+ const fn = componentFunctionOf(decl.init);
878
+ if (fn)
879
+ addFirstParamName(fn);
857
880
  }
858
881
  }
859
882
  }
@@ -1260,14 +1283,16 @@ async function loader(source) {
1260
1283
  ? scannedTables.componentPropsTable?.[`${resourcePath}-${owner}`]?.[varName]
1261
1284
  : undefined;
1262
1285
  if (!possibilities) {
1286
+ const candidates = [];
1263
1287
  for (const key of Object.keys(scannedTables.componentPropsTable || {})) {
1264
1288
  if (!key.startsWith(`${resourcePath}-`))
1265
1289
  continue;
1266
- if (scannedTables.componentPropsTable?.[key]?.[varName]) {
1267
- possibilities = scannedTables.componentPropsTable[key][varName];
1268
- break;
1269
- }
1290
+ const entries = scannedTables.componentPropsTable?.[key]?.[varName];
1291
+ if (entries)
1292
+ candidates.push(...entries);
1270
1293
  }
1294
+ if (candidates.length > 0)
1295
+ possibilities = candidates;
1271
1296
  }
1272
1297
  if (!possibilities || possibilities.length === 0)
1273
1298
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/turbopack-loader",
3
- "version": "18.3.12",
3
+ "version": "18.3.14",
4
4
  "description": "Plumeria Turbopack-loader",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",
@@ -29,8 +29,8 @@
29
29
  "zero-virtual.css"
30
30
  ],
31
31
  "dependencies": {
32
- "@plumeria/compiler": "^18.3.12",
33
- "@plumeria/utils": "^18.3.12"
32
+ "@plumeria/compiler": "^18.3.14",
33
+ "@plumeria/utils": "^18.3.14"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@swc/core": "1.15.47",