@unocss/vite 0.50.3 → 0.50.5

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/index.cjs CHANGED
@@ -6,14 +6,14 @@ const UnocssInspector = require('@unocss/inspector');
6
6
  const core = require('@unocss/core');
7
7
  const pluginutils = require('@rollup/pluginutils');
8
8
  const config = require('@unocss/config');
9
- const crypto = require('crypto');
9
+ const node_crypto = require('node:crypto');
10
10
  const MagicString = require('magic-string');
11
- const path = require('path');
12
- const fs = require('fs/promises');
11
+ const node_path = require('node:path');
12
+ const fs = require('node:fs/promises');
13
13
  const fg = require('fast-glob');
14
14
  const remapping = require('@ampproject/remapping');
15
- const fs$1 = require('fs');
16
- const url = require('url');
15
+ const fs$1 = require('node:fs');
16
+ const node_url = require('node:url');
17
17
 
18
18
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
19
19
 
@@ -31,15 +31,15 @@ const VIRTUAL_ENTRY_ALIAS = [
31
31
  /^(?:virtual:)?uno(?::(.+))?\.css(\?.*)?$/
32
32
  ];
33
33
  const LAYER_MARK_ALL = "__ALL__";
34
- const RESOLVED_ID_WITH_QUERY_RE = /[\/\\]__uno(?:(_.*?))?\.css(\?.*)?$/;
35
- const RESOLVED_ID_RE = /[\/\\]__uno(?:(_.*?))?\.css$/;
34
+ const RESOLVED_ID_WITH_QUERY_RE = /\0?[\/\\]__uno(?:(_.*?))?\.css(\?.*)?$/;
35
+ const RESOLVED_ID_RE = /\0?[\/\\]__uno(?:(_.*?))?\.css$/;
36
36
  function resolveId(id) {
37
37
  if (id.match(RESOLVED_ID_WITH_QUERY_RE))
38
38
  return id;
39
39
  for (const alias of VIRTUAL_ENTRY_ALIAS) {
40
40
  const match = id.match(alias);
41
41
  if (match) {
42
- return match[1] ? `/__uno_${match[1]}.css` : "/__uno.css";
42
+ return match[1] ? `\0/__uno_${match[1]}.css` : "\0/__uno.css";
43
43
  }
44
44
  }
45
45
  }
@@ -168,7 +168,7 @@ function getPath(id) {
168
168
  }
169
169
 
170
170
  function getHash(input, length = 8) {
171
- return crypto.createHash("sha256").update(input).digest("hex").slice(0, length);
171
+ return node_crypto.createHash("sha256").update(input).digest("hex").slice(0, length);
172
172
  }
173
173
 
174
174
  function replaceAsync(string, searchValue, replacer) {
@@ -300,7 +300,7 @@ async function setupExtraContent(ctx, shouldWatch = false) {
300
300
  });
301
301
  watcher.on("all", (type, file) => {
302
302
  if (type === "add" || type === "change") {
303
- const absolutePath = path.resolve(root, file);
303
+ const absolutePath = node_path.resolve(root, file);
304
304
  tasks.push(extractFile(absolutePath));
305
305
  }
306
306
  });
@@ -395,15 +395,15 @@ function GlobalModeBuildPlugin(ctx) {
395
395
  },
396
396
  async configResolved(config) {
397
397
  const distDirs = [
398
- path.resolve(config.root, config.build.outDir)
398
+ node_path.resolve(config.root, config.build.outDir)
399
399
  ];
400
400
  if (config.build.rollupOptions.output) {
401
401
  const outputOptions = config.build.rollupOptions.output;
402
402
  const outputDirs = Array.isArray(outputOptions) ? outputOptions.map((option) => option.dir).filter(Boolean) : outputOptions.dir ? [outputOptions.dir] : [];
403
403
  outputDirs.forEach((dir) => {
404
404
  distDirs.push(dir);
405
- if (!path.isAbsolute(dir))
406
- distDirs.push(path.resolve(config.root, dir));
405
+ if (!node_path.isAbsolute(dir))
406
+ distDirs.push(node_path.resolve(config.root, dir));
407
407
  });
408
408
  }
409
409
  const cssPostPlugin = config.plugins.find((i) => i.name === "vite:css-post");
@@ -659,7 +659,10 @@ function GlobalModeDevPlugin({ uno, tokens, tasks, flushTasks, affectedModules,
659
659
  if (!layer)
660
660
  return null;
661
661
  const { hash, css } = await generateCSS(layer);
662
- return `__uno_hash_${hash}{--:'';}${css}`;
662
+ return {
663
+ code: `__uno_hash_${hash}{--:'';}${css}`,
664
+ map: { mappings: "" }
665
+ };
663
666
  }
664
667
  },
665
668
  {
@@ -691,7 +694,12 @@ if (!import.meta.url.includes('?'))
691
694
  })()`;
692
695
  hmr = `
693
696
  if (import.meta.hot) {${hmr}}`;
694
- return code + hmr;
697
+ const s = new MagicString__default(code);
698
+ s.append(hmr);
699
+ return {
700
+ code: s.toString(),
701
+ map: s.generateMap()
702
+ };
695
703
  }
696
704
  }
697
705
  }
@@ -1182,7 +1190,7 @@ function createTransformerPlugins(ctx) {
1182
1190
  }));
1183
1191
  }
1184
1192
 
1185
- const _dirname = typeof __dirname !== "undefined" ? __dirname : path.dirname(url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href))));
1193
+ const _dirname = typeof __dirname !== "undefined" ? __dirname : node_path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href))));
1186
1194
  const DEVTOOLS_MODULE_ID = "virtual:unocss-devtools";
1187
1195
  const MOCK_CLASSES_MODULE_ID = "virtual:unocss-mock-classes";
1188
1196
  const MOCK_CLASSES_PATH = "/@unocss/mock-classes";
@@ -1292,7 +1300,7 @@ function createDevtoolsPlugin(ctx) {
1292
1300
  if (id === DEVTOOLS_PATH) {
1293
1301
  if (!clientCode) {
1294
1302
  clientCode = [
1295
- await fs__default$1.promises.readFile(path.resolve(_dirname, "client.mjs"), "utf-8"),
1303
+ await fs__default$1.promises.readFile(node_path.resolve(_dirname, "client.mjs"), "utf-8"),
1296
1304
  `import('${MOCK_CLASSES_MODULE_ID}')`,
1297
1305
  `import('${DEVTOOLS_CSS_PATH}')`
1298
1306
  ].join("\n").replace("__POST_PATH__", (config.server?.origin ?? "") + POST_PATH);
package/dist/index.mjs CHANGED
@@ -2,14 +2,14 @@ import UnocssInspector from '@unocss/inspector';
2
2
  import { cssIdRE, createGenerator, BetterMap, notNull, expandVariantGroup, attributifyRE, escapeRegExp, toEscapedSelector } from '@unocss/core';
3
3
  import { createFilter } from '@rollup/pluginutils';
4
4
  import { loadConfig } from '@unocss/config';
5
- import { createHash } from 'crypto';
5
+ import { createHash } from 'node:crypto';
6
6
  import MagicString from 'magic-string';
7
- import { resolve, isAbsolute, dirname } from 'path';
8
- import fs from 'fs/promises';
7
+ import { resolve, isAbsolute, dirname } from 'node:path';
8
+ import fs from 'node:fs/promises';
9
9
  import fg from 'fast-glob';
10
10
  import remapping from '@ampproject/remapping';
11
- import fs$1 from 'fs';
12
- import { fileURLToPath } from 'url';
11
+ import fs$1 from 'node:fs';
12
+ import { fileURLToPath } from 'node:url';
13
13
 
14
14
  const defaultExclude = [cssIdRE];
15
15
  const defaultInclude = [/\.(vue|svelte|[jt]sx|mdx?|astro|elm|php|phtml|html)($|\?)/];
@@ -18,15 +18,15 @@ const VIRTUAL_ENTRY_ALIAS = [
18
18
  /^(?:virtual:)?uno(?::(.+))?\.css(\?.*)?$/
19
19
  ];
20
20
  const LAYER_MARK_ALL = "__ALL__";
21
- const RESOLVED_ID_WITH_QUERY_RE = /[\/\\]__uno(?:(_.*?))?\.css(\?.*)?$/;
22
- const RESOLVED_ID_RE = /[\/\\]__uno(?:(_.*?))?\.css$/;
21
+ const RESOLVED_ID_WITH_QUERY_RE = /\0?[\/\\]__uno(?:(_.*?))?\.css(\?.*)?$/;
22
+ const RESOLVED_ID_RE = /\0?[\/\\]__uno(?:(_.*?))?\.css$/;
23
23
  function resolveId(id) {
24
24
  if (id.match(RESOLVED_ID_WITH_QUERY_RE))
25
25
  return id;
26
26
  for (const alias of VIRTUAL_ENTRY_ALIAS) {
27
27
  const match = id.match(alias);
28
28
  if (match) {
29
- return match[1] ? `/__uno_${match[1]}.css` : "/__uno.css";
29
+ return match[1] ? `\0/__uno_${match[1]}.css` : "\0/__uno.css";
30
30
  }
31
31
  }
32
32
  }
@@ -646,7 +646,10 @@ function GlobalModeDevPlugin({ uno, tokens, tasks, flushTasks, affectedModules,
646
646
  if (!layer)
647
647
  return null;
648
648
  const { hash, css } = await generateCSS(layer);
649
- return `__uno_hash_${hash}{--:'';}${css}`;
649
+ return {
650
+ code: `__uno_hash_${hash}{--:'';}${css}`,
651
+ map: { mappings: "" }
652
+ };
650
653
  }
651
654
  },
652
655
  {
@@ -678,7 +681,12 @@ if (!import.meta.url.includes('?'))
678
681
  })()`;
679
682
  hmr = `
680
683
  if (import.meta.hot) {${hmr}}`;
681
- return code + hmr;
684
+ const s = new MagicString(code);
685
+ s.append(hmr);
686
+ return {
687
+ code: s.toString(),
688
+ map: s.generateMap()
689
+ };
682
690
  }
683
691
  }
684
692
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/vite",
3
- "version": "0.50.3",
3
+ "version": "0.50.5",
4
4
  "description": "The Vite plugin for UnoCSS",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -44,18 +44,18 @@
44
44
  "dependencies": {
45
45
  "@ampproject/remapping": "^2.2.0",
46
46
  "@rollup/pluginutils": "^5.0.2",
47
- "@unocss/config": "0.50.3",
48
- "@unocss/core": "0.50.3",
49
- "@unocss/inspector": "0.50.3",
50
- "@unocss/scope": "0.50.3",
51
- "@unocss/transformer-directives": "0.50.3",
52
47
  "chokidar": "^3.5.3",
53
48
  "fast-glob": "^3.2.12",
54
- "magic-string": "^0.30.0"
49
+ "magic-string": "^0.30.0",
50
+ "@unocss/config": "0.50.5",
51
+ "@unocss/core": "0.50.5",
52
+ "@unocss/inspector": "0.50.5",
53
+ "@unocss/scope": "0.50.5",
54
+ "@unocss/transformer-directives": "0.50.5"
55
55
  },
56
56
  "devDependencies": {
57
- "@unocss/shared-integration": "0.50.3",
58
- "vite": "^4.1.4"
57
+ "vite": "^4.2.0",
58
+ "@unocss/shared-integration": "0.50.5"
59
59
  },
60
60
  "scripts": {
61
61
  "build": "unbuild",