@unocss/cli 0.60.1 → 0.60.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/cli.mjs CHANGED
@@ -2,7 +2,7 @@ import process from 'node:process';
2
2
  import { cac } from 'cac';
3
3
  import { loadConfig } from '@unocss/config';
4
4
  import { toArray } from '@unocss/core';
5
- import { b as build, v as version, h as handleError } from './shared/cli.DlYwVAtE.mjs';
5
+ import { b as build, v as version, h as handleError } from './shared/cli.BaBiPj_j.mjs';
6
6
  import 'node:fs';
7
7
  import 'pathe';
8
8
  import 'fast-glob';
package/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ import 'consola';
6
6
  import 'colorette';
7
7
  import 'perfect-debounce';
8
8
  import '@unocss/core';
9
- export { b as build, r as resolveOptions } from './shared/cli.DlYwVAtE.mjs';
9
+ export { b as build, r as resolveOptions } from './shared/cli.BaBiPj_j.mjs';
10
10
  import '@rollup/pluginutils';
11
11
  import '@unocss/config';
12
12
  import 'magic-string';
@@ -187,7 +187,6 @@ async function applyTransformers(ctx, original, id, enforce = "default") {
187
187
  }
188
188
  }
189
189
  if (code !== original) {
190
- ctx.affectedModules.add(id);
191
190
  return {
192
191
  code,
193
192
  map: remapping(maps, (_, ctx2) => {
@@ -214,7 +213,7 @@ function restoreSkipCode(code, map) {
214
213
  return code;
215
214
  }
216
215
 
217
- const version = "0.60.1";
216
+ const version = "0.60.3";
218
217
 
219
218
  const defaultConfig = {
220
219
  envMode: "build",
@@ -346,13 +345,40 @@ async function build(_options) {
346
345
  }))
347
346
  );
348
347
  }
349
- const { css, matched } = await ctx.uno.generate(
350
- [...postTransform.map(({ code, transformedCode }) => (transformedCode ?? code).replace(SKIP_COMMENT_RE, ""))].join("\n"),
351
- {
348
+ const firstIdType = postTransform[0].id.split(".").pop();
349
+ const isSameFileType = postTransform.every(({ id }) => id.split(".").pop() === firstIdType);
350
+ let css;
351
+ let matched;
352
+ if (isSameFileType) {
353
+ const { css: _css, matched: _matched } = await ctx.uno.generate(
354
+ [...postTransform.map(({ code, transformedCode }) => (transformedCode ?? code).replace(SKIP_COMMENT_RE, ""))].join("\n"),
355
+ {
356
+ preflights: options2.preflights,
357
+ minify: options2.minify,
358
+ id: postTransform[0].id
359
+ }
360
+ );
361
+ css = _css;
362
+ matched = _matched;
363
+ } else {
364
+ const result = await Promise.all(postTransform.map(({ code, transformedCode, id }) => ctx.uno.generate(transformedCode ?? code, {
352
365
  preflights: options2.preflights,
353
- minify: options2.minify
354
- }
355
- );
366
+ minify: options2.minify,
367
+ id
368
+ })));
369
+ const cssCollection = {};
370
+ result.forEach(({ css: css2, layers }) => {
371
+ css2.split(/\/\*.*?\*\//g).filter(Boolean).forEach((c, i) => {
372
+ if (!cssCollection[layers[i]]) {
373
+ cssCollection[layers[i]] = c.split("\n");
374
+ } else {
375
+ cssCollection[layers[i]] = [.../* @__PURE__ */ new Set([...cssCollection[layers[i]], ...c.split("\n")])];
376
+ }
377
+ });
378
+ });
379
+ css = result[0].layers.map((layer) => `/* layer: ${layer} */${cssCollection[layer].join("\n")}`).join("\n");
380
+ matched = new Set(result.map(({ matched: matched2 }) => [...matched2]).flat());
381
+ }
356
382
  if (options2.stdout) {
357
383
  process$1.stdout.write(css);
358
384
  return;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/cli",
3
3
  "type": "module",
4
- "version": "0.60.1",
4
+ "version": "0.60.3",
5
5
  "description": "CLI for UnoCSS",
6
6
  "author": {
7
7
  "name": "Johann Schopplich",
@@ -50,9 +50,9 @@
50
50
  "magic-string": "^0.30.10",
51
51
  "pathe": "^1.1.2",
52
52
  "perfect-debounce": "^1.0.0",
53
- "@unocss/config": "0.60.1",
54
- "@unocss/core": "0.60.1",
55
- "@unocss/preset-uno": "0.60.1"
53
+ "@unocss/config": "0.60.3",
54
+ "@unocss/core": "0.60.3",
55
+ "@unocss/preset-uno": "0.60.3"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "unbuild",