@plumeria/vite-plugin 4.1.1 → 4.1.2

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 +46 -0
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -297,7 +297,31 @@ export function plumeria(options = {}) {
297
297
  }
298
298
  return false;
299
299
  };
300
+ const hasDynamicAccess = (expr) => {
301
+ if (t.isMemberExpression(expr) && t.isIdentifier(expr.object)) {
302
+ const info = localCreateStyles[expr.object.value];
303
+ if (info && info.hasDynamicAccess)
304
+ return true;
305
+ }
306
+ if (t.isIdentifier(expr)) {
307
+ const info = localCreateStyles[expr.value];
308
+ if (info && info.hasDynamicAccess)
309
+ return true;
310
+ }
311
+ if (t.isConditionalExpression(expr)) {
312
+ return (hasDynamicAccess(expr.consequent) ||
313
+ hasDynamicAccess(expr.alternate));
314
+ }
315
+ if (t.isBinaryExpression(expr) &&
316
+ (expr.operator === '&&' ||
317
+ expr.operator === '||' ||
318
+ expr.operator === '??')) {
319
+ return (hasDynamicAccess(expr.left) || hasDynamicAccess(expr.right));
320
+ }
321
+ return false;
322
+ };
300
323
  const allStatic = args.every((arg) => checkStatic(arg.expression));
324
+ const anyDynamic = args.some((arg) => hasDynamicAccess(arg.expression));
301
325
  if (allStatic && args.length > 0) {
302
326
  const merged = args.reduce((acc, arg) => {
303
327
  const expr = arg.expression;
@@ -334,6 +358,28 @@ export function plumeria(options = {}) {
334
358
  });
335
359
  }
336
360
  }
361
+ else if (anyDynamic) {
362
+ const processExpr = (expr) => {
363
+ if (t.isIdentifier(expr)) {
364
+ const info = localCreateStyles[expr.value];
365
+ if (info && info.hasDynamicAccess) {
366
+ excludedSpans.add(expr.span.start);
367
+ }
368
+ }
369
+ else if (t.isConditionalExpression(expr)) {
370
+ processExpr(expr.consequent);
371
+ processExpr(expr.alternate);
372
+ }
373
+ else if (t.isBinaryExpression(expr) &&
374
+ (expr.operator === '&&' ||
375
+ expr.operator === '||' ||
376
+ expr.operator === '??')) {
377
+ processExpr(expr.left);
378
+ processExpr(expr.right);
379
+ }
380
+ };
381
+ args.forEach((arg) => processExpr(arg.expression));
382
+ }
337
383
  else {
338
384
  const processExpr = (expr) => {
339
385
  if (t.isMemberExpression(expr) &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/vite-plugin",
3
- "version": "4.1.1",
3
+ "version": "4.1.2",
4
4
  "type": "module",
5
5
  "description": "Plumeria Vite plugin",
6
6
  "author": "Refirst 11",
@@ -22,7 +22,7 @@
22
22
  "dist/"
23
23
  ],
24
24
  "dependencies": {
25
- "@plumeria/utils": "^4.1.1"
25
+ "@plumeria/utils": "^4.1.2"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@swc/core": "1.15.8",