@plumeria/turbopack-loader 4.1.1 → 4.1.3
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 +46 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -250,7 +250,31 @@ async function loader(source) {
|
|
|
250
250
|
}
|
|
251
251
|
return false;
|
|
252
252
|
};
|
|
253
|
+
const hasDynamicAccess = (expr) => {
|
|
254
|
+
if (utils_1.t.isMemberExpression(expr) && utils_1.t.isIdentifier(expr.object)) {
|
|
255
|
+
const info = localCreateStyles[expr.object.value];
|
|
256
|
+
if (info && info.hasDynamicAccess)
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
if (utils_1.t.isIdentifier(expr)) {
|
|
260
|
+
const info = localCreateStyles[expr.value];
|
|
261
|
+
if (info && info.hasDynamicAccess)
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
if (utils_1.t.isConditionalExpression(expr)) {
|
|
265
|
+
return (hasDynamicAccess(expr.consequent) ||
|
|
266
|
+
hasDynamicAccess(expr.alternate));
|
|
267
|
+
}
|
|
268
|
+
if (utils_1.t.isBinaryExpression(expr) &&
|
|
269
|
+
(expr.operator === '&&' ||
|
|
270
|
+
expr.operator === '||' ||
|
|
271
|
+
expr.operator === '??')) {
|
|
272
|
+
return hasDynamicAccess(expr.left) || hasDynamicAccess(expr.right);
|
|
273
|
+
}
|
|
274
|
+
return false;
|
|
275
|
+
};
|
|
253
276
|
const allStatic = args.every((arg) => checkStatic(arg.expression));
|
|
277
|
+
const anyDynamic = args.some((arg) => hasDynamicAccess(arg.expression));
|
|
254
278
|
if (allStatic && args.length > 0) {
|
|
255
279
|
const merged = args.reduce((acc, arg) => {
|
|
256
280
|
const expr = arg.expression;
|
|
@@ -287,6 +311,28 @@ async function loader(source) {
|
|
|
287
311
|
});
|
|
288
312
|
}
|
|
289
313
|
}
|
|
314
|
+
else if (anyDynamic) {
|
|
315
|
+
const processExpr = (expr) => {
|
|
316
|
+
if (utils_1.t.isIdentifier(expr)) {
|
|
317
|
+
const info = localCreateStyles[expr.value];
|
|
318
|
+
if (info && info.hasDynamicAccess) {
|
|
319
|
+
excludedSpans.add(expr.span.start);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
else if (utils_1.t.isConditionalExpression(expr)) {
|
|
323
|
+
processExpr(expr.consequent);
|
|
324
|
+
processExpr(expr.alternate);
|
|
325
|
+
}
|
|
326
|
+
else if (utils_1.t.isBinaryExpression(expr) &&
|
|
327
|
+
(expr.operator === '&&' ||
|
|
328
|
+
expr.operator === '||' ||
|
|
329
|
+
expr.operator === '??')) {
|
|
330
|
+
processExpr(expr.left);
|
|
331
|
+
processExpr(expr.right);
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
args.forEach((arg) => processExpr(arg.expression));
|
|
335
|
+
}
|
|
290
336
|
else {
|
|
291
337
|
const processExpr = (expr) => {
|
|
292
338
|
if (utils_1.t.isMemberExpression(expr) &&
|
|
@@ -308,7 +354,6 @@ async function loader(source) {
|
|
|
308
354
|
else if (utils_1.t.isIdentifier(expr)) {
|
|
309
355
|
const info = localCreateStyles[expr.value];
|
|
310
356
|
if (info) {
|
|
311
|
-
info.hasDynamicAccess = true;
|
|
312
357
|
excludedSpans.add(expr.span.start);
|
|
313
358
|
replacements.push({
|
|
314
359
|
start: expr.span.start - ast.span.start,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/turbopack-loader",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.3",
|
|
4
4
|
"description": "Plumeria Turbopack-loader",
|
|
5
5
|
"author": "Refirst 11",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"zero-virtual.css"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@plumeria/utils": "^4.1.
|
|
25
|
+
"@plumeria/utils": "^4.1.3"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@swc/core": "1.15.8",
|