@unocss/vite 0.54.3 → 0.55.0
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 +30 -20
- package/dist/index.mjs +30 -20
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -814,22 +814,36 @@ function PerModuleModePlugin({ uno, filter }) {
|
|
|
814
814
|
{
|
|
815
815
|
name: "unocss:module-scope:pre",
|
|
816
816
|
enforce: "pre",
|
|
817
|
+
resolveId(id) {
|
|
818
|
+
const entry = resolveId(id);
|
|
819
|
+
if (entry)
|
|
820
|
+
return entry;
|
|
821
|
+
},
|
|
822
|
+
async load(id) {
|
|
823
|
+
const layer = resolveLayer(getPath(id));
|
|
824
|
+
if (!layer)
|
|
825
|
+
return null;
|
|
826
|
+
const { css } = await uno.generate("", { preflights: true });
|
|
827
|
+
if (!css)
|
|
828
|
+
return null;
|
|
829
|
+
return {
|
|
830
|
+
code: css,
|
|
831
|
+
map: null
|
|
832
|
+
};
|
|
833
|
+
},
|
|
817
834
|
async transform(code, id) {
|
|
818
835
|
if (!filter(code, id))
|
|
819
836
|
return;
|
|
820
837
|
const hash = getHash(id);
|
|
821
|
-
const
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
});
|
|
825
|
-
if (!css)
|
|
838
|
+
const hasScope = code.match(SCOPE_IMPORT_RE);
|
|
839
|
+
const { css } = await uno.generate(code, { id, scope: hasScope ? `.${hash}` : void 0, preflights: false });
|
|
840
|
+
if (!css && !hasScope)
|
|
826
841
|
return null;
|
|
842
|
+
if (hasScope)
|
|
843
|
+
code = code.replace(SCOPE_IMPORT_RE, ` from 'data:text/javascript;base64,${node_buffer.Buffer.from(`export default () => "${hash}"`).toString("base64")}'`);
|
|
827
844
|
moduleMap.set(hash, [id, css]);
|
|
828
845
|
invalidate(hash);
|
|
829
|
-
return
|
|
830
|
-
code: `import "${VIRTUAL_PREFIX}${hash}.css";${code}`,
|
|
831
|
-
map: null
|
|
832
|
-
};
|
|
846
|
+
return null;
|
|
833
847
|
}
|
|
834
848
|
},
|
|
835
849
|
{
|
|
@@ -842,18 +856,14 @@ function PerModuleModePlugin({ uno, filter }) {
|
|
|
842
856
|
if (!filter(code, id))
|
|
843
857
|
return;
|
|
844
858
|
const hash = getHash(id);
|
|
845
|
-
const hasScope = code.match(SCOPE_IMPORT_RE);
|
|
846
|
-
const { css } = await uno.generate(code, { id, scope: hasScope ? `.${hash}` : void 0, preflights: false });
|
|
847
|
-
if (!css && !hasScope)
|
|
848
|
-
return null;
|
|
849
|
-
if (hasScope)
|
|
850
|
-
code = code.replace(SCOPE_IMPORT_RE, ` from 'data:text/javascript;base64,${node_buffer.Buffer.from(`export default () => "${hash}"`).toString("base64")}'`);
|
|
851
|
-
moduleMap.set(hash, [id, css]);
|
|
852
859
|
invalidate(hash);
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
860
|
+
const module = moduleMap.get(hash) || [];
|
|
861
|
+
if (module.length) {
|
|
862
|
+
return {
|
|
863
|
+
code: `import "${VIRTUAL_PREFIX}${hash}.css";${code}`,
|
|
864
|
+
map: null
|
|
865
|
+
};
|
|
866
|
+
}
|
|
857
867
|
},
|
|
858
868
|
resolveId(id) {
|
|
859
869
|
return id.startsWith(VIRTUAL_PREFIX) ? id : null;
|
package/dist/index.mjs
CHANGED
|
@@ -800,22 +800,36 @@ function PerModuleModePlugin({ uno, filter }) {
|
|
|
800
800
|
{
|
|
801
801
|
name: "unocss:module-scope:pre",
|
|
802
802
|
enforce: "pre",
|
|
803
|
+
resolveId(id) {
|
|
804
|
+
const entry = resolveId(id);
|
|
805
|
+
if (entry)
|
|
806
|
+
return entry;
|
|
807
|
+
},
|
|
808
|
+
async load(id) {
|
|
809
|
+
const layer = resolveLayer(getPath(id));
|
|
810
|
+
if (!layer)
|
|
811
|
+
return null;
|
|
812
|
+
const { css } = await uno.generate("", { preflights: true });
|
|
813
|
+
if (!css)
|
|
814
|
+
return null;
|
|
815
|
+
return {
|
|
816
|
+
code: css,
|
|
817
|
+
map: null
|
|
818
|
+
};
|
|
819
|
+
},
|
|
803
820
|
async transform(code, id) {
|
|
804
821
|
if (!filter(code, id))
|
|
805
822
|
return;
|
|
806
823
|
const hash = getHash(id);
|
|
807
|
-
const
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
});
|
|
811
|
-
if (!css)
|
|
824
|
+
const hasScope = code.match(SCOPE_IMPORT_RE);
|
|
825
|
+
const { css } = await uno.generate(code, { id, scope: hasScope ? `.${hash}` : void 0, preflights: false });
|
|
826
|
+
if (!css && !hasScope)
|
|
812
827
|
return null;
|
|
828
|
+
if (hasScope)
|
|
829
|
+
code = code.replace(SCOPE_IMPORT_RE, ` from 'data:text/javascript;base64,${Buffer.from(`export default () => "${hash}"`).toString("base64")}'`);
|
|
813
830
|
moduleMap.set(hash, [id, css]);
|
|
814
831
|
invalidate(hash);
|
|
815
|
-
return
|
|
816
|
-
code: `import "${VIRTUAL_PREFIX}${hash}.css";${code}`,
|
|
817
|
-
map: null
|
|
818
|
-
};
|
|
832
|
+
return null;
|
|
819
833
|
}
|
|
820
834
|
},
|
|
821
835
|
{
|
|
@@ -828,18 +842,14 @@ function PerModuleModePlugin({ uno, filter }) {
|
|
|
828
842
|
if (!filter(code, id))
|
|
829
843
|
return;
|
|
830
844
|
const hash = getHash(id);
|
|
831
|
-
const hasScope = code.match(SCOPE_IMPORT_RE);
|
|
832
|
-
const { css } = await uno.generate(code, { id, scope: hasScope ? `.${hash}` : void 0, preflights: false });
|
|
833
|
-
if (!css && !hasScope)
|
|
834
|
-
return null;
|
|
835
|
-
if (hasScope)
|
|
836
|
-
code = code.replace(SCOPE_IMPORT_RE, ` from 'data:text/javascript;base64,${Buffer.from(`export default () => "${hash}"`).toString("base64")}'`);
|
|
837
|
-
moduleMap.set(hash, [id, css]);
|
|
838
845
|
invalidate(hash);
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
846
|
+
const module = moduleMap.get(hash) || [];
|
|
847
|
+
if (module.length) {
|
|
848
|
+
return {
|
|
849
|
+
code: `import "${VIRTUAL_PREFIX}${hash}.css";${code}`,
|
|
850
|
+
map: null
|
|
851
|
+
};
|
|
852
|
+
}
|
|
843
853
|
},
|
|
844
854
|
resolveId(id) {
|
|
845
855
|
return id.startsWith(VIRTUAL_PREFIX) ? id : null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.55.0",
|
|
4
4
|
"description": "The Vite plugin for UnoCSS",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,15 +47,15 @@
|
|
|
47
47
|
"chokidar": "^3.5.3",
|
|
48
48
|
"fast-glob": "^3.3.1",
|
|
49
49
|
"magic-string": "^0.30.2",
|
|
50
|
-
"@unocss/config": "0.
|
|
51
|
-
"@unocss/core": "0.
|
|
52
|
-
"@unocss/inspector": "0.
|
|
53
|
-
"@unocss/scope": "0.
|
|
54
|
-
"@unocss/transformer-directives": "0.
|
|
50
|
+
"@unocss/config": "0.55.0",
|
|
51
|
+
"@unocss/core": "0.55.0",
|
|
52
|
+
"@unocss/inspector": "0.55.0",
|
|
53
|
+
"@unocss/scope": "0.55.0",
|
|
54
|
+
"@unocss/transformer-directives": "0.55.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"vite": "^4.4.9",
|
|
58
|
-
"@unocss/shared-integration": "0.
|
|
58
|
+
"@unocss/shared-integration": "0.55.0"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build": "unbuild",
|