@plumeria/vite-plugin 6.0.1 → 6.0.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 +20 -7
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -68,12 +68,21 @@ export function plumeria(options = {}) {
68
68
  dependencies.push(depPath);
69
69
  this.addWatchFile(depPath);
70
70
  };
71
- const scannedTables = scanAll();
72
71
  const ast = parseSync(source, {
73
72
  syntax: 'typescript',
74
73
  tsx: true,
75
74
  target: 'es2022',
76
75
  });
76
+ for (const node of ast.body) {
77
+ if (node.type === 'ImportDeclaration') {
78
+ const sourcePath = node.source.value;
79
+ const actualPath = resolveImportPath(sourcePath, id);
80
+ if (actualPath) {
81
+ addDependency(actualPath);
82
+ }
83
+ }
84
+ }
85
+ const scannedTables = scanAll();
77
86
  const localConsts = collectLocalConsts(ast);
78
87
  const resourcePath = id;
79
88
  const importMap = {};
@@ -82,7 +91,6 @@ export function plumeria(options = {}) {
82
91
  const sourcePath = node.source.value;
83
92
  const actualPath = resolveImportPath(sourcePath, resourcePath);
84
93
  if (actualPath) {
85
- addDependency(actualPath);
86
94
  node.specifiers.forEach((specifier) => {
87
95
  if (specifier.type === 'ImportSpecifier') {
88
96
  const importedName = specifier.imported
@@ -166,6 +174,11 @@ export function plumeria(options = {}) {
166
174
  const localCreateStyles = {};
167
175
  const replacements = [];
168
176
  const extractedSheets = [];
177
+ const addSheet = (sheet) => {
178
+ if (!extractedSheets.includes(sheet)) {
179
+ extractedSheets.push(sheet);
180
+ }
181
+ };
169
182
  const processedDecls = new Set();
170
183
  const idSpans = new Set();
171
184
  const excludedSpans = new Set();
@@ -199,7 +212,7 @@ export function plumeria(options = {}) {
199
212
  const records = getStyleRecords(key, style, 2);
200
213
  extractOndemandStyles(style, extractedSheets, scannedTables);
201
214
  records.forEach((r) => {
202
- extractedSheets.push(r.sheet);
215
+ addSheet(r.sheet);
203
216
  });
204
217
  const atomMap = {};
205
218
  records.forEach((r) => (atomMap[r.key] = r.hash));
@@ -356,7 +369,7 @@ export function plumeria(options = {}) {
356
369
  if (typeof style === 'object' && style !== null) {
357
370
  const records = getStyleRecords(key, style, 2);
358
371
  extractOndemandStyles(style, extractedSheets, scannedTables);
359
- records.forEach((r) => extractedSheets.push(r.sheet));
372
+ records.forEach((r) => addSheet(r.sheet));
360
373
  }
361
374
  });
362
375
  }
@@ -388,7 +401,7 @@ export function plumeria(options = {}) {
388
401
  if (typeof style === 'object' && style !== null) {
389
402
  const records = getStyleRecords(propName, style, 2);
390
403
  extractOndemandStyles(style, extractedSheets, scannedTables);
391
- records.forEach((r) => extractedSheets.push(r.sheet));
404
+ records.forEach((r) => addSheet(r.sheet));
392
405
  const atomMap = {};
393
406
  records.forEach((r) => (atomMap[r.key] = r.hash));
394
407
  if (Object.keys(atomMap).length > 0) {
@@ -597,7 +610,7 @@ export function plumeria(options = {}) {
597
610
  extractOndemandStyles(baseStyle, extractedSheets, scannedTables);
598
611
  const hash = genBase36Hash(baseStyle, 1, 8);
599
612
  const records = getStyleRecords(hash, baseStyle, 2);
600
- records.forEach((r) => extractedSheets.push(r.sheet));
613
+ records.forEach((r) => addSheet(r.sheet));
601
614
  const className = records
602
615
  .map((r) => r.hash)
603
616
  .join(' ');
@@ -636,7 +649,7 @@ export function plumeria(options = {}) {
636
649
  extractOndemandStyles(currentStyle, extractedSheets, scannedTables);
637
650
  const hash = genBase36Hash(currentStyle, 1, 8);
638
651
  const records = getStyleRecords(hash, currentStyle, 2);
639
- records.forEach((r) => extractedSheets.push(r.sheet));
652
+ records.forEach((r) => addSheet(r.sheet));
640
653
  const className = records
641
654
  .map((r) => r.hash)
642
655
  .join(' ');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/vite-plugin",
3
- "version": "6.0.1",
3
+ "version": "6.0.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": "^6.0.1"
25
+ "@plumeria/utils": "^6.0.2"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@swc/core": "1.15.8",