@unocss/vite 66.7.2 → 66.7.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.
Files changed (2) hide show
  1. package/dist/index.mjs +28 -6
  2. package/package.json +6 -6
package/dist/index.mjs CHANGED
@@ -357,18 +357,39 @@ function restoreSkipCode(code, map) {
357
357
  }
358
358
  //#endregion
359
359
  //#region ../../virtual-shared/integration/src/transformers.ts
360
+ const transformerCache = /* @__PURE__ */ new WeakMap();
361
+ function getTransformers(ctx, enforce) {
362
+ const configured = ctx.uno.config.transformers;
363
+ if (!configured?.length) return;
364
+ let grouped = transformerCache.get(configured);
365
+ if (!grouped) {
366
+ grouped = {
367
+ pre: [],
368
+ default: [],
369
+ post: []
370
+ };
371
+ for (const transformer of configured) grouped[transformer.enforce || "default"].push(transformer);
372
+ transformerCache.set(configured, grouped);
373
+ }
374
+ return grouped[enforce];
375
+ }
360
376
  async function applyTransformers(ctx, original, id, enforce = "default") {
361
377
  if (original.includes("@unocss-ignore")) return;
362
- const transformers = (ctx.uno.config.transformers || []).filter((i) => (i.enforce || "default") === enforce);
363
- if (!transformers.length) return;
364
- const skipMap = /* @__PURE__ */ new Map();
378
+ const transformers = getTransformers(ctx, enforce);
379
+ if (!transformers?.length) return;
365
380
  let code = original;
366
- let s = new MagicString(transformSkipCode(code, skipMap, SKIP_COMMENT_RE, "@unocss-skip-placeholder-"));
381
+ let skipMap;
382
+ let s;
367
383
  const maps = [];
368
384
  for (const t of transformers) {
369
385
  if (t.idFilter) {
370
386
  if (!t.idFilter(id)) continue;
371
387
  } else if (!ctx.filter(code, id)) continue;
388
+ if (t.codeFilter && !t.codeFilter(code, id)) continue;
389
+ if (!s) {
390
+ skipMap = /* @__PURE__ */ new Map();
391
+ s = new MagicString(transformSkipCode(code, skipMap, SKIP_COMMENT_RE, "@unocss-skip-placeholder-"));
392
+ }
372
393
  await t.transform(s, id, ctx);
373
394
  if (s.hasChanged()) {
374
395
  code = restoreSkipCode(s.toString(), skipMap);
@@ -424,7 +445,8 @@ async function setupContentExtractor(ctx, shouldWatch = false) {
424
445
  }
425
446
  });
426
447
  }
427
- await Promise.all(files.map(extractFile));
448
+ const BATCH_SIZE = 50;
449
+ for (let i = 0; i < files.length; i += BATCH_SIZE) await Promise.all(files.slice(i, i + BATCH_SIZE).map(extractFile));
428
450
  }
429
451
  }
430
452
  //#endregion
@@ -689,7 +711,7 @@ function GlobalModeDevPlugin(ctx) {
689
711
  }
690
712
  }
691
713
  onInvalidate(() => {
692
- invalidate(10, new Set([...entries, ...affectedModules]));
714
+ invalidate(10, /* @__PURE__ */ new Set([...entries, ...affectedModules]));
693
715
  });
694
716
  return [{
695
717
  name: "unocss:global",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/vite",
3
3
  "type": "module",
4
- "version": "66.7.2",
4
+ "version": "66.7.3",
5
5
  "description": "The Vite plugin for UnoCSS",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -46,14 +46,14 @@
46
46
  "chokidar": "^5.0.0",
47
47
  "magic-string": "^0.30.21",
48
48
  "pathe": "^2.0.3",
49
- "tinyglobby": "^0.2.16",
49
+ "tinyglobby": "^0.2.17",
50
50
  "unplugin-utils": "^0.3.1",
51
- "@unocss/config": "66.7.2",
52
- "@unocss/core": "66.7.2",
53
- "@unocss/inspector": "66.7.2"
51
+ "@unocss/config": "66.7.3",
52
+ "@unocss/core": "66.7.3",
53
+ "@unocss/inspector": "66.7.3"
54
54
  },
55
55
  "devDependencies": {
56
- "vite": "^8.0.13"
56
+ "vite": "^8.1.0"
57
57
  },
58
58
  "scripts": {
59
59
  "build": "tsdown --config-loader unrun",