@plumeria/turbopack-loader 18.3.13 → 18.3.15

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 +37 -7
  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' ||
@@ -277,6 +289,13 @@ async function loader(source) {
277
289
  mergedCreateTable[rootId] !== undefined ||
278
290
  mergedVariantsTable[rootId] !== undefined);
279
291
  if (!isPlumeriaStyle) {
292
+ const origin = rootId ? localImports[rootId] : undefined;
293
+ const failure = origin
294
+ ? (0, utils_1.resolveFileError)(origin.actualPath, origin.importedName)
295
+ : undefined;
296
+ if (failure) {
297
+ throwCompilationError(`Plumeria: ${failure.message} (${path.basename(failure.filePath)})`);
298
+ }
280
299
  throwCompilationError(`Plumeria: Dynamic or unresolvable style object "${getSource(node)}" is not supported.`, node);
281
300
  }
282
301
  }
@@ -322,13 +341,18 @@ async function loader(source) {
322
341
  node: statement,
323
342
  });
324
343
  }
344
+ else if (statement?.type === 'CallExpression') {
345
+ const fn = componentFunctionOf(statement);
346
+ if (fn)
347
+ components.push({ name: 'default', node: fn });
348
+ }
325
349
  else if (utils_1.t.isVariableDeclaration(statement)) {
326
350
  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
- }
351
+ if (!utils_1.t.isIdentifier(decl.id))
352
+ continue;
353
+ const fn = componentFunctionOf(decl.init);
354
+ if (fn)
355
+ components.push({ name: decl.id.value, node: fn });
332
356
  }
333
357
  }
334
358
  }
@@ -848,12 +872,18 @@ async function loader(source) {
848
872
  if (isFunctionNode(statement)) {
849
873
  addFirstParamName(statement);
850
874
  }
875
+ else if (statement?.type === 'CallExpression') {
876
+ const fn = componentFunctionOf(statement);
877
+ if (fn)
878
+ addFirstParamName(fn);
879
+ }
851
880
  else if (utils_1.t.isVariableDeclaration(statement)) {
852
881
  for (const decl of statement.declarations) {
853
882
  if (!utils_1.t.isIdentifier(decl.id) || !decl.init)
854
883
  continue;
855
- if (isFunctionNode(decl.init))
856
- addFirstParamName(decl.init);
884
+ const fn = componentFunctionOf(decl.init);
885
+ if (fn)
886
+ addFirstParamName(fn);
857
887
  }
858
888
  }
859
889
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/turbopack-loader",
3
- "version": "18.3.13",
3
+ "version": "18.3.15",
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.13",
33
- "@plumeria/utils": "^18.3.13"
32
+ "@plumeria/compiler": "^18.3.15",
33
+ "@plumeria/utils": "^18.3.15"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@swc/core": "1.15.47",