@plumeria/vite-plugin 4.0.5 → 4.1.1

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 +11 -17
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { createFilter } from 'vite';
2
2
  import { parseSync } from '@swc/core';
3
3
  import path from 'path';
4
4
  import { genBase36Hash } from 'zss-engine';
5
- import { tables, traverse, getStyleRecords, collectLocalConsts, objectExpressionToObject, scanForCreateStatic, scanForCreateTheme, scanForKeyframes, scanForViewTransition, t, extractOndemandStyles, } from '@plumeria/utils';
5
+ import { tables, traverse, getStyleRecords, collectLocalConsts, objectExpressionToObject, scanForCreateStatic, scanForCreateTheme, scanForKeyframes, scanForViewTransition, t, extractOndemandStyles, deepMerge, } from '@plumeria/utils';
6
6
  const TARGET_EXTENSIONS = ['ts', 'tsx', 'js', 'jsx'];
7
7
  const EXTENSION_PATTERN = /\.(ts|tsx|js|jsx)$/;
8
8
  export function plumeria(options = {}) {
@@ -243,11 +243,10 @@ export function plumeria(options = {}) {
243
243
  if (styleInfo && !styleInfo.hasDynamicAccess) {
244
244
  const atomMap = styleInfo.hashMap[node.property.value];
245
245
  if (atomMap) {
246
- const combinedHash = Object.values(atomMap).join(' ');
247
246
  replacements.push({
248
247
  start: node.span.start - ast.span.start,
249
248
  end: node.span.end - ast.span.start,
250
- content: JSON.stringify(combinedHash),
249
+ content: JSON.stringify(atomMap),
251
250
  });
252
251
  }
253
252
  }
@@ -299,32 +298,27 @@ export function plumeria(options = {}) {
299
298
  return false;
300
299
  };
301
300
  const allStatic = args.every((arg) => checkStatic(arg.expression));
302
- if (allStatic) {
303
- const merged = {};
304
- args.forEach((arg) => {
301
+ if (allStatic && args.length > 0) {
302
+ const merged = args.reduce((acc, arg) => {
305
303
  const expr = arg.expression;
306
304
  if (t.isObjectExpression(expr)) {
307
- excludedSpans.add(expr.span.start);
308
305
  const obj = objectExpressionToObject(expr, tables.staticTable, tables.keyframesHashTable, tables.viewTransitionHashTable, tables.themeTable);
309
- obj && Object.assign(merged, obj);
306
+ return obj ? deepMerge(acc, obj) : acc;
310
307
  }
311
308
  else if (t.isMemberExpression(expr) &&
312
309
  t.isIdentifier(expr.object) &&
313
310
  t.isIdentifier(expr.property)) {
314
- excludedSpans.add(expr.span.start);
315
311
  const styleInfo = localCreateStyles[expr.object.value];
316
- if (styleInfo) {
317
- Object.assign(merged, styleInfo.obj[expr.property.value]);
318
- }
312
+ return styleInfo
313
+ ? deepMerge(acc, styleInfo.obj[expr.property.value])
314
+ : acc;
319
315
  }
320
316
  else if (t.isIdentifier(expr)) {
321
- excludedSpans.add(expr.span.start);
322
317
  const styleInfo = localCreateStyles[expr.value];
323
- if (styleInfo) {
324
- Object.assign(merged, styleInfo.obj);
325
- }
318
+ return styleInfo ? deepMerge(acc, styleInfo.obj) : acc;
326
319
  }
327
- });
320
+ return acc;
321
+ }, {});
328
322
  if (Object.keys(merged).length > 0) {
329
323
  extractOndemandStyles(merged, extractedSheets);
330
324
  const hash = genBase36Hash(merged, 1, 8);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/vite-plugin",
3
- "version": "4.0.5",
3
+ "version": "4.1.1",
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.0.5"
25
+ "@plumeria/utils": "^4.1.1"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@swc/core": "1.15.8",