@vizejs/unplugin 0.101.0 → 0.104.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/esbuild.mjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as vizeUnplugin } from "./unplugin-
|
|
1
|
+
import { t as vizeUnplugin } from "./unplugin-DdUoejrP.mjs";
|
|
2
2
|
export { vizeUnplugin as default, vizeUnplugin };
|
package/dist/rollup.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import fs from "node:fs";
|
|
|
2
2
|
import { createUnplugin } from "unplugin";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import * as native from "@vizejs/native";
|
|
5
|
-
import
|
|
5
|
+
import { generateSfcScopeId, wrapSfcScopedPreprocessorStyle } from "@vizejs/native";
|
|
6
6
|
import { transform } from "oxc-transform";
|
|
7
7
|
//#region src/filter.ts
|
|
8
8
|
function createFilter(include, exclude) {
|
|
@@ -40,34 +40,7 @@ function hasDelegatedStyles(compiled) {
|
|
|
40
40
|
return compiled.styles.some((style) => needsPreprocessor(style) || isCssModule(style));
|
|
41
41
|
}
|
|
42
42
|
function generateScopeId(filename, root, isProduction, source) {
|
|
43
|
-
|
|
44
|
-
const input = isProduction ? `${relative}\n${source.replace(/\r\n/g, "\n")}` : relative;
|
|
45
|
-
return createHash("sha256").update(input).digest("hex").slice(0, 8);
|
|
46
|
-
}
|
|
47
|
-
function extractStyleBlocks(source) {
|
|
48
|
-
const blocks = [];
|
|
49
|
-
const styleRegex = /<style([^>]*)>([\s\S]*?)<\/style>/gi;
|
|
50
|
-
let match = null;
|
|
51
|
-
let index = 0;
|
|
52
|
-
while ((match = styleRegex.exec(source)) !== null) {
|
|
53
|
-
const attrs = match[1];
|
|
54
|
-
const content = match[2];
|
|
55
|
-
const src = attrs.match(/\bsrc=["']([^"']+)["']/)?.[1] ?? null;
|
|
56
|
-
const lang = attrs.match(/\blang=["']([^"']+)["']/)?.[1] ?? null;
|
|
57
|
-
const scoped = /\bscoped\b/.test(attrs);
|
|
58
|
-
const moduleMatch = attrs.match(/\bmodule(?:=["']([^"']+)["'])?/);
|
|
59
|
-
const moduleValue = moduleMatch ? moduleMatch[1] || true : false;
|
|
60
|
-
blocks.push({
|
|
61
|
-
content,
|
|
62
|
-
src,
|
|
63
|
-
lang,
|
|
64
|
-
scoped,
|
|
65
|
-
module: moduleValue,
|
|
66
|
-
index
|
|
67
|
-
});
|
|
68
|
-
index++;
|
|
69
|
-
}
|
|
70
|
-
return blocks;
|
|
43
|
+
return generateSfcScopeId(filename, root, isProduction, source);
|
|
71
44
|
}
|
|
72
45
|
function supportsTemplateOnlyHmr(output) {
|
|
73
46
|
return /(?:^|\n)(?:_sfc_main|__sfc__)\.render\s*=\s*render\b/m.test(output);
|
|
@@ -139,19 +112,17 @@ ${output}`;
|
|
|
139
112
|
return output;
|
|
140
113
|
}
|
|
141
114
|
function wrapScopedPreprocessorStyle(content, scoped, lang) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
return `${hoisted.length > 0 ? `${hoisted.join("\n")}\n\n` : ""}[${scoped}] {\n${body.join("\n")}\n}`;
|
|
115
|
+
return wrapSfcScopedPreprocessorStyle(content, scoped, lang);
|
|
116
|
+
}
|
|
117
|
+
function toStyleBlockInfo(block) {
|
|
118
|
+
return {
|
|
119
|
+
content: block.content,
|
|
120
|
+
src: block.src ?? null,
|
|
121
|
+
lang: block.lang ?? null,
|
|
122
|
+
scoped: block.scoped,
|
|
123
|
+
module: block.module ? block.moduleName ?? true : false,
|
|
124
|
+
index: block.index
|
|
125
|
+
};
|
|
155
126
|
}
|
|
156
127
|
//#endregion
|
|
157
128
|
//#region src/compiler.ts
|
|
@@ -178,26 +149,25 @@ function compileVueModule(filePath, source, options, cache) {
|
|
|
178
149
|
warnings: []
|
|
179
150
|
};
|
|
180
151
|
const scopeId = generateScopeId(filePath, options.root, options.isProduction, source);
|
|
181
|
-
const hasScoped = /<style[^>]*\bscoped\b/.test(source);
|
|
182
152
|
const result = compileSfc(source, {
|
|
183
153
|
filename: filePath,
|
|
184
154
|
sourceMap: options.sourceMap,
|
|
185
155
|
ssr: options.ssr,
|
|
186
156
|
vapor: options.vapor,
|
|
187
157
|
customRenderer: options.customRenderer,
|
|
188
|
-
scopeId:
|
|
158
|
+
scopeId: `data-v-${scopeId}`
|
|
189
159
|
});
|
|
190
160
|
if (result.errors.length > 0) throw new Error(result.errors.join("\n"));
|
|
191
161
|
const compiled = {
|
|
192
162
|
code: result.code,
|
|
193
163
|
css: result.css,
|
|
194
164
|
scopeId,
|
|
195
|
-
hasScoped,
|
|
165
|
+
hasScoped: result.hasScoped,
|
|
196
166
|
templateHash: result.templateHash,
|
|
197
167
|
styleHash: result.styleHash,
|
|
198
168
|
scriptHash: result.scriptHash,
|
|
199
169
|
macroArtifacts: result.macroArtifacts ?? [],
|
|
200
|
-
styles:
|
|
170
|
+
styles: result.styles.map(toStyleBlockInfo)
|
|
201
171
|
};
|
|
202
172
|
cache.set(filePath, {
|
|
203
173
|
compiled,
|
package/dist/webpack.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/unplugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.104.0",
|
|
4
4
|
"description": "Experimental unplugin-based Vue SFC integration for rollup, webpack, and esbuild powered by Vize",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
"vue",
|
|
14
14
|
"webpack"
|
|
15
15
|
],
|
|
16
|
+
"homepage": "https://github.com/ubugeeei/vize",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/ubugeeei/vize/issues"
|
|
19
|
+
},
|
|
16
20
|
"license": "MIT",
|
|
17
21
|
"repository": {
|
|
18
22
|
"type": "git",
|
|
@@ -51,7 +55,7 @@
|
|
|
51
55
|
"access": "public"
|
|
52
56
|
},
|
|
53
57
|
"dependencies": {
|
|
54
|
-
"@vizejs/native": "0.
|
|
58
|
+
"@vizejs/native": "0.104.0",
|
|
55
59
|
"oxc-transform": "0.130.0",
|
|
56
60
|
"unplugin": "3.0.0"
|
|
57
61
|
},
|
|
@@ -64,6 +68,9 @@
|
|
|
64
68
|
"vue": "3.6.0-beta.10",
|
|
65
69
|
"webpack": "5.106.2"
|
|
66
70
|
},
|
|
71
|
+
"engines": {
|
|
72
|
+
"node": ">=22"
|
|
73
|
+
},
|
|
67
74
|
"scripts": {
|
|
68
75
|
"build": "vp pack",
|
|
69
76
|
"dev": "vp pack --watch",
|