@plumeria/turbopack-loader 18.2.12 → 18.2.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.
- package/dist/index.js +48 -40
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -110,6 +110,45 @@ const namedParamsOf = (params) => {
|
|
|
110
110
|
}
|
|
111
111
|
return named.length > 0 ? named : undefined;
|
|
112
112
|
};
|
|
113
|
+
const styleFunctionsOf = (objExpr) => {
|
|
114
|
+
const styleFunctions = {};
|
|
115
|
+
objExpr.properties.forEach((prop) => {
|
|
116
|
+
if (prop.type !== 'KeyValueProperty' || prop.key.type !== 'Identifier')
|
|
117
|
+
return;
|
|
118
|
+
const func = prop.value;
|
|
119
|
+
if (func.type !== 'ArrowFunctionExpression' &&
|
|
120
|
+
func.type !== 'FunctionExpression')
|
|
121
|
+
return;
|
|
122
|
+
const params = func.params.map((p) => {
|
|
123
|
+
if (utils_1.t.isIdentifier(p))
|
|
124
|
+
return p.value;
|
|
125
|
+
if (typeof p === 'object' &&
|
|
126
|
+
p !== null &&
|
|
127
|
+
'pat' in p &&
|
|
128
|
+
utils_1.t.isIdentifier(p.pat))
|
|
129
|
+
return p.pat.value;
|
|
130
|
+
return 'arg';
|
|
131
|
+
});
|
|
132
|
+
let actualBody = func.body;
|
|
133
|
+
if (actualBody?.type === 'ParenthesisExpression')
|
|
134
|
+
actualBody = actualBody.expression;
|
|
135
|
+
if (actualBody?.type === 'BlockStatement') {
|
|
136
|
+
const first = actualBody.stmts?.[0];
|
|
137
|
+
if (first?.type === 'ReturnStatement')
|
|
138
|
+
actualBody = first.argument;
|
|
139
|
+
if (actualBody?.type === 'ParenthesisExpression')
|
|
140
|
+
actualBody = actualBody.expression;
|
|
141
|
+
}
|
|
142
|
+
if (actualBody && actualBody.type === 'ObjectExpression') {
|
|
143
|
+
styleFunctions[prop.key.value] = {
|
|
144
|
+
params,
|
|
145
|
+
named: namedParamsOf(func.params),
|
|
146
|
+
body: actualBody,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
return styleFunctions;
|
|
151
|
+
};
|
|
113
152
|
const foldDynamicVars = (vars) => {
|
|
114
153
|
const grouped = new Map();
|
|
115
154
|
[...vars]
|
|
@@ -283,6 +322,7 @@ async function loader(source) {
|
|
|
283
322
|
const keyframesImportMap = {};
|
|
284
323
|
const viewTransitionImportMap = {};
|
|
285
324
|
const createImportMap = {};
|
|
325
|
+
const createFunctionImportMap = {};
|
|
286
326
|
const variantsImportMap = {};
|
|
287
327
|
const createThemeImportMap = {};
|
|
288
328
|
const createStaticImportMap = {};
|
|
@@ -347,6 +387,9 @@ async function loader(source) {
|
|
|
347
387
|
createImportMap[localName] =
|
|
348
388
|
scannedTables.createHashTable[uniqueKey];
|
|
349
389
|
}
|
|
390
|
+
if (scannedTables.createFunctionTable[uniqueKey]) {
|
|
391
|
+
createFunctionImportMap[localName] = styleFunctionsOf(scannedTables.createFunctionTable[uniqueKey]);
|
|
392
|
+
}
|
|
350
393
|
if (scannedTables.variantsHashTable[uniqueKey]) {
|
|
351
394
|
variantsImportMap[localName] =
|
|
352
395
|
scannedTables.variantsHashTable[uniqueKey];
|
|
@@ -505,44 +548,7 @@ async function loader(source) {
|
|
|
505
548
|
records.forEach((r) => (atomMap[r.key] = r.hash));
|
|
506
549
|
hashMap[key] = atomMap;
|
|
507
550
|
});
|
|
508
|
-
const styleFunctions =
|
|
509
|
-
const objExpr = init.arguments[0].expression;
|
|
510
|
-
objExpr.properties.forEach((prop) => {
|
|
511
|
-
if (prop.type !== 'KeyValueProperty' ||
|
|
512
|
-
prop.key.type !== 'Identifier')
|
|
513
|
-
return;
|
|
514
|
-
const func = prop.value;
|
|
515
|
-
if (func.type !== 'ArrowFunctionExpression' &&
|
|
516
|
-
func.type !== 'FunctionExpression')
|
|
517
|
-
return;
|
|
518
|
-
const params = func.params.map((p) => {
|
|
519
|
-
if (utils_1.t.isIdentifier(p))
|
|
520
|
-
return p.value;
|
|
521
|
-
if (typeof p === 'object' &&
|
|
522
|
-
p !== null &&
|
|
523
|
-
'pat' in p &&
|
|
524
|
-
utils_1.t.isIdentifier(p.pat))
|
|
525
|
-
return p.pat.value;
|
|
526
|
-
return 'arg';
|
|
527
|
-
});
|
|
528
|
-
let actualBody = func.body;
|
|
529
|
-
if (actualBody?.type === 'ParenthesisExpression')
|
|
530
|
-
actualBody = actualBody.expression;
|
|
531
|
-
if (actualBody?.type === 'BlockStatement') {
|
|
532
|
-
const first = actualBody.stmts?.[0];
|
|
533
|
-
if (first?.type === 'ReturnStatement')
|
|
534
|
-
actualBody = first.argument;
|
|
535
|
-
if (actualBody?.type === 'ParenthesisExpression')
|
|
536
|
-
actualBody = actualBody.expression;
|
|
537
|
-
}
|
|
538
|
-
if (actualBody && actualBody.type === 'ObjectExpression') {
|
|
539
|
-
styleFunctions[prop.key.value] = {
|
|
540
|
-
params,
|
|
541
|
-
named: namedParamsOf(func.params),
|
|
542
|
-
body: actualBody,
|
|
543
|
-
};
|
|
544
|
-
}
|
|
545
|
-
});
|
|
551
|
+
const styleFunctions = styleFunctionsOf(init.arguments[0].expression);
|
|
546
552
|
if (utils_1.t.isIdentifier(node.id)) {
|
|
547
553
|
idSpans.add(node.id.span.start);
|
|
548
554
|
}
|
|
@@ -884,7 +890,8 @@ async function loader(source) {
|
|
|
884
890
|
if (!utils_1.t.isIdentifier(callee.object) || !utils_1.t.isIdentifier(callee.property))
|
|
885
891
|
return null;
|
|
886
892
|
const styleInfo = localCreateStyles[callee.object.value];
|
|
887
|
-
const func = styleInfo?.functions?.[callee.property.value]
|
|
893
|
+
const func = styleInfo?.functions?.[callee.property.value] ??
|
|
894
|
+
createFunctionImportMap[callee.object.value]?.[callee.property.value];
|
|
888
895
|
if (!func)
|
|
889
896
|
return null;
|
|
890
897
|
const callArgs = expr.arguments;
|
|
@@ -2024,7 +2031,8 @@ async function loader(source) {
|
|
|
2024
2031
|
utils_1.t.isIdentifier(callee.property)) {
|
|
2025
2032
|
const objectName = callee.object.value;
|
|
2026
2033
|
const propertyName = callee.property.value;
|
|
2027
|
-
if (localCreateStyles[objectName]?.functions?.[propertyName]
|
|
2034
|
+
if (localCreateStyles[objectName]?.functions?.[propertyName] ||
|
|
2035
|
+
createFunctionImportMap[objectName]?.[propertyName]) {
|
|
2028
2036
|
dynamicFnCalls.push(node);
|
|
2029
2037
|
}
|
|
2030
2038
|
const alias = plumeriaAliases[objectName];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/turbopack-loader",
|
|
3
|
-
"version": "18.2.
|
|
3
|
+
"version": "18.2.14",
|
|
4
4
|
"description": "Plumeria Turbopack-loader",
|
|
5
5
|
"author": "Refirst 11",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"zero-virtual.css"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@plumeria/compiler": "^18.2.
|
|
26
|
-
"@plumeria/utils": "^18.2.
|
|
25
|
+
"@plumeria/compiler": "^18.2.14",
|
|
26
|
+
"@plumeria/utils": "^18.2.14"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@swc/core": "1.15.47",
|