@unocss/vite 0.26.3 → 0.27.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.
- package/dist/index.cjs +12 -21
- package/dist/index.mjs +11 -21
- package/package.json +7 -6
package/dist/index.cjs
CHANGED
|
@@ -7,10 +7,12 @@ const pluginutils = require('@rollup/pluginutils');
|
|
|
7
7
|
const config = require('@unocss/config');
|
|
8
8
|
const core = require('@unocss/core');
|
|
9
9
|
const crypto = require('crypto');
|
|
10
|
+
const MagicString = require('magic-string-extra');
|
|
10
11
|
|
|
11
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
12
13
|
|
|
13
14
|
const UnocssInspector__default = /*#__PURE__*/_interopDefaultLegacy(UnocssInspector);
|
|
15
|
+
const MagicString__default = /*#__PURE__*/_interopDefaultLegacy(MagicString);
|
|
14
16
|
|
|
15
17
|
const regexCssId = /\.(css|postcss|sass|scss|less|stylus|styl)$/;
|
|
16
18
|
const defaultExclude = [regexCssId];
|
|
@@ -366,7 +368,7 @@ function GlobalModeDevPlugin({ uno, tokens, onInvalidate, extract, filter }) {
|
|
|
366
368
|
return code.replace("return hot", "hot.send = (data) => socket.send(data);return hot;");
|
|
367
369
|
if (entries.has(getPath(id)) && code.includes("import.meta.hot")) {
|
|
368
370
|
const snippet = `
|
|
369
|
-
if (import.meta.hot) { try { import.meta.hot.send('${WS_EVENT_PREFIX}${lastServed}') } catch {} }`;
|
|
371
|
+
if (import.meta.hot) { try { import.meta.hot.send('${WS_EVENT_PREFIX}${lastServed}') } catch (e) { console.warn('[unocss-hmr]', e) } }`;
|
|
370
372
|
return code + snippet;
|
|
371
373
|
}
|
|
372
374
|
}
|
|
@@ -630,11 +632,11 @@ function ConfigHMRPlugin(ctx) {
|
|
|
630
632
|
}
|
|
631
633
|
|
|
632
634
|
function initTransformerPlugins(ctx) {
|
|
633
|
-
async function applyTransformers(
|
|
635
|
+
async function applyTransformers(code, id, enforce) {
|
|
634
636
|
const transformers = (ctx.uno.config.transformers || []).filter((i) => i.enforce === enforce);
|
|
635
637
|
if (!transformers.length)
|
|
636
|
-
return
|
|
637
|
-
|
|
638
|
+
return;
|
|
639
|
+
const s = new MagicString__default(code);
|
|
638
640
|
for (const t of transformers) {
|
|
639
641
|
if (t.idFilter) {
|
|
640
642
|
if (!t.idFilter(id))
|
|
@@ -642,40 +644,29 @@ function initTransformerPlugins(ctx) {
|
|
|
642
644
|
} else if (!ctx.filter(code, id)) {
|
|
643
645
|
continue;
|
|
644
646
|
}
|
|
645
|
-
|
|
646
|
-
if (result == null)
|
|
647
|
-
continue;
|
|
648
|
-
if (typeof result === "string") {
|
|
649
|
-
code = result;
|
|
650
|
-
} else {
|
|
651
|
-
code = result.code;
|
|
652
|
-
if (result.map && "sourcemapChain" in c)
|
|
653
|
-
c.sourcemapChain.push(result.map);
|
|
654
|
-
}
|
|
647
|
+
await t.transform(s, id, ctx);
|
|
655
648
|
}
|
|
656
|
-
|
|
657
|
-
return null;
|
|
658
|
-
return code;
|
|
649
|
+
return s.toRollupResult(true, { hires: true });
|
|
659
650
|
}
|
|
660
651
|
return [
|
|
661
652
|
{
|
|
662
|
-
name: "unocss:transformers:
|
|
653
|
+
name: "unocss:transformers:default",
|
|
663
654
|
transform(code, id) {
|
|
664
|
-
return applyTransformers(
|
|
655
|
+
return applyTransformers(code, id);
|
|
665
656
|
}
|
|
666
657
|
},
|
|
667
658
|
{
|
|
668
659
|
name: "unocss:transformers:pre",
|
|
669
660
|
enforce: "pre",
|
|
670
661
|
transform(code, id) {
|
|
671
|
-
return applyTransformers(
|
|
662
|
+
return applyTransformers(code, id, "pre");
|
|
672
663
|
}
|
|
673
664
|
},
|
|
674
665
|
{
|
|
675
666
|
name: "unocss:transformers:post",
|
|
676
667
|
enforce: "post",
|
|
677
668
|
transform(code, id) {
|
|
678
|
-
return applyTransformers(
|
|
669
|
+
return applyTransformers(code, id, "post");
|
|
679
670
|
}
|
|
680
671
|
}
|
|
681
672
|
];
|
package/dist/index.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { createFilter } from '@rollup/pluginutils';
|
|
|
3
3
|
import { createConfigLoader } from '@unocss/config';
|
|
4
4
|
import { createGenerator, BetterMap } from '@unocss/core';
|
|
5
5
|
import { createHash } from 'crypto';
|
|
6
|
+
import MagicString from 'magic-string-extra';
|
|
6
7
|
|
|
7
8
|
const regexCssId = /\.(css|postcss|sass|scss|less|stylus|styl)$/;
|
|
8
9
|
const defaultExclude = [regexCssId];
|
|
@@ -358,7 +359,7 @@ function GlobalModeDevPlugin({ uno, tokens, onInvalidate, extract, filter }) {
|
|
|
358
359
|
return code.replace("return hot", "hot.send = (data) => socket.send(data);return hot;");
|
|
359
360
|
if (entries.has(getPath(id)) && code.includes("import.meta.hot")) {
|
|
360
361
|
const snippet = `
|
|
361
|
-
if (import.meta.hot) { try { import.meta.hot.send('${WS_EVENT_PREFIX}${lastServed}') } catch {} }`;
|
|
362
|
+
if (import.meta.hot) { try { import.meta.hot.send('${WS_EVENT_PREFIX}${lastServed}') } catch (e) { console.warn('[unocss-hmr]', e) } }`;
|
|
362
363
|
return code + snippet;
|
|
363
364
|
}
|
|
364
365
|
}
|
|
@@ -622,11 +623,11 @@ function ConfigHMRPlugin(ctx) {
|
|
|
622
623
|
}
|
|
623
624
|
|
|
624
625
|
function initTransformerPlugins(ctx) {
|
|
625
|
-
async function applyTransformers(
|
|
626
|
+
async function applyTransformers(code, id, enforce) {
|
|
626
627
|
const transformers = (ctx.uno.config.transformers || []).filter((i) => i.enforce === enforce);
|
|
627
628
|
if (!transformers.length)
|
|
628
|
-
return
|
|
629
|
-
|
|
629
|
+
return;
|
|
630
|
+
const s = new MagicString(code);
|
|
630
631
|
for (const t of transformers) {
|
|
631
632
|
if (t.idFilter) {
|
|
632
633
|
if (!t.idFilter(id))
|
|
@@ -634,40 +635,29 @@ function initTransformerPlugins(ctx) {
|
|
|
634
635
|
} else if (!ctx.filter(code, id)) {
|
|
635
636
|
continue;
|
|
636
637
|
}
|
|
637
|
-
|
|
638
|
-
if (result == null)
|
|
639
|
-
continue;
|
|
640
|
-
if (typeof result === "string") {
|
|
641
|
-
code = result;
|
|
642
|
-
} else {
|
|
643
|
-
code = result.code;
|
|
644
|
-
if (result.map && "sourcemapChain" in c)
|
|
645
|
-
c.sourcemapChain.push(result.map);
|
|
646
|
-
}
|
|
638
|
+
await t.transform(s, id, ctx);
|
|
647
639
|
}
|
|
648
|
-
|
|
649
|
-
return null;
|
|
650
|
-
return code;
|
|
640
|
+
return s.toRollupResult(true, { hires: true });
|
|
651
641
|
}
|
|
652
642
|
return [
|
|
653
643
|
{
|
|
654
|
-
name: "unocss:transformers:
|
|
644
|
+
name: "unocss:transformers:default",
|
|
655
645
|
transform(code, id) {
|
|
656
|
-
return applyTransformers(
|
|
646
|
+
return applyTransformers(code, id);
|
|
657
647
|
}
|
|
658
648
|
},
|
|
659
649
|
{
|
|
660
650
|
name: "unocss:transformers:pre",
|
|
661
651
|
enforce: "pre",
|
|
662
652
|
transform(code, id) {
|
|
663
|
-
return applyTransformers(
|
|
653
|
+
return applyTransformers(code, id, "pre");
|
|
664
654
|
}
|
|
665
655
|
},
|
|
666
656
|
{
|
|
667
657
|
name: "unocss:transformers:post",
|
|
668
658
|
enforce: "post",
|
|
669
659
|
transform(code, id) {
|
|
670
|
-
return applyTransformers(
|
|
660
|
+
return applyTransformers(code, id, "post");
|
|
671
661
|
}
|
|
672
662
|
}
|
|
673
663
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.1",
|
|
4
4
|
"description": "The Vite plugin for UnoCSS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unocss",
|
|
@@ -35,11 +35,12 @@
|
|
|
35
35
|
"types": "dist/index.d.ts",
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@rollup/pluginutils": "^4.1.2",
|
|
38
|
-
"@unocss/config": "0.
|
|
39
|
-
"@unocss/core": "0.
|
|
40
|
-
"@unocss/inspector": "0.
|
|
41
|
-
"@unocss/scope": "0.
|
|
42
|
-
"@unocss/transformer-directives": "0.
|
|
38
|
+
"@unocss/config": "0.27.1",
|
|
39
|
+
"@unocss/core": "0.27.1",
|
|
40
|
+
"@unocss/inspector": "0.27.1",
|
|
41
|
+
"@unocss/scope": "0.27.1",
|
|
42
|
+
"@unocss/transformer-directives": "0.27.1",
|
|
43
|
+
"magic-string-extra": "^0.1.2"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
46
|
"vite": "^2.8.4"
|