@plumeria/turbopack-loader 18.3.11 → 18.3.12
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 +36 -25
- 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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/turbopack-loader",
|
|
3
|
-
"version": "18.3.
|
|
3
|
+
"version": "18.3.12",
|
|
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.12",
|
|
33
|
+
"@plumeria/utils": "^18.3.12"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@swc/core": "1.15.47",
|