@plumeria/turbopack-loader 18.3.11 → 18.3.13
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.
- package/dist/index.js +42 -29
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -79,6 +79,18 @@ const ensureProductionCss = (virtualFilePath, options) => {
|
|
|
79
79
|
}
|
|
80
80
|
return productionCss;
|
|
81
81
|
};
|
|
82
|
+
const unwrapExport = (node) => {
|
|
83
|
+
if (node?.type === 'ExportDeclaration')
|
|
84
|
+
return node.declaration;
|
|
85
|
+
if (node?.type === 'ExportDefaultDeclaration')
|
|
86
|
+
return node.decl;
|
|
87
|
+
if (node?.type === 'ExportDefaultExpression')
|
|
88
|
+
return node.expression;
|
|
89
|
+
return node;
|
|
90
|
+
};
|
|
91
|
+
const isFunctionNode = (node) => node?.type === 'FunctionDeclaration' ||
|
|
92
|
+
node?.type === 'FunctionExpression' ||
|
|
93
|
+
node?.type === 'ArrowFunctionExpression';
|
|
82
94
|
const isStaticArgValue = (node) => node.type === 'StringLiteral' ||
|
|
83
95
|
node.type === 'NumericLiteral' ||
|
|
84
96
|
node.type === 'BooleanLiteral' ||
|
|
@@ -303,9 +315,12 @@ async function loader(source) {
|
|
|
303
315
|
}
|
|
304
316
|
const components = [];
|
|
305
317
|
for (const node of ast.body) {
|
|
306
|
-
const statement =
|
|
307
|
-
if (statement
|
|
308
|
-
components.push({
|
|
318
|
+
const statement = unwrapExport(node);
|
|
319
|
+
if (isFunctionNode(statement)) {
|
|
320
|
+
components.push({
|
|
321
|
+
name: statement.identifier?.value ?? 'default',
|
|
322
|
+
node: statement,
|
|
323
|
+
});
|
|
309
324
|
}
|
|
310
325
|
else if (utils_1.t.isVariableDeclaration(statement)) {
|
|
311
326
|
for (const decl of statement.declarations) {
|
|
@@ -819,30 +834,26 @@ async function loader(source) {
|
|
|
819
834
|
});
|
|
820
835
|
const jsxOpeningElementMap = new Map();
|
|
821
836
|
const componentParamNames = new Set();
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
if (utils_1.t.
|
|
825
|
-
|
|
837
|
+
const addFirstParamName = (fn) => {
|
|
838
|
+
const p = fn.params[0];
|
|
839
|
+
if (utils_1.t.isIdentifier(p)) {
|
|
840
|
+
componentParamNames.add(p.value);
|
|
826
841
|
}
|
|
827
|
-
else if (utils_1.t.
|
|
828
|
-
|
|
829
|
-
declarations = node.declaration.declarations;
|
|
842
|
+
else if (p?.pat && utils_1.t.isIdentifier(p.pat)) {
|
|
843
|
+
componentParamNames.add(p.pat.value);
|
|
830
844
|
}
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
else if (p.pat && utils_1.t.isIdentifier(p.pat)) {
|
|
844
|
-
componentParamNames.add(p.pat.value);
|
|
845
|
-
}
|
|
845
|
+
};
|
|
846
|
+
for (const node of ast.body) {
|
|
847
|
+
const statement = unwrapExport(node);
|
|
848
|
+
if (isFunctionNode(statement)) {
|
|
849
|
+
addFirstParamName(statement);
|
|
850
|
+
}
|
|
851
|
+
else if (utils_1.t.isVariableDeclaration(statement)) {
|
|
852
|
+
for (const decl of statement.declarations) {
|
|
853
|
+
if (!utils_1.t.isIdentifier(decl.id) || !decl.init)
|
|
854
|
+
continue;
|
|
855
|
+
if (isFunctionNode(decl.init))
|
|
856
|
+
addFirstParamName(decl.init);
|
|
846
857
|
}
|
|
847
858
|
}
|
|
848
859
|
}
|
|
@@ -1249,14 +1260,16 @@ async function loader(source) {
|
|
|
1249
1260
|
? scannedTables.componentPropsTable?.[`${resourcePath}-${owner}`]?.[varName]
|
|
1250
1261
|
: undefined;
|
|
1251
1262
|
if (!possibilities) {
|
|
1263
|
+
const candidates = [];
|
|
1252
1264
|
for (const key of Object.keys(scannedTables.componentPropsTable || {})) {
|
|
1253
1265
|
if (!key.startsWith(`${resourcePath}-`))
|
|
1254
1266
|
continue;
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
}
|
|
1267
|
+
const entries = scannedTables.componentPropsTable?.[key]?.[varName];
|
|
1268
|
+
if (entries)
|
|
1269
|
+
candidates.push(...entries);
|
|
1259
1270
|
}
|
|
1271
|
+
if (candidates.length > 0)
|
|
1272
|
+
possibilities = candidates;
|
|
1260
1273
|
}
|
|
1261
1274
|
if (!possibilities || possibilities.length === 0)
|
|
1262
1275
|
return false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/turbopack-loader",
|
|
3
|
-
"version": "18.3.
|
|
3
|
+
"version": "18.3.13",
|
|
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.
|
|
33
|
-
"@plumeria/utils": "^18.3.
|
|
32
|
+
"@plumeria/compiler": "^18.3.13",
|
|
33
|
+
"@plumeria/utils": "^18.3.13"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@swc/core": "1.15.47",
|