@vizejs/vite-plugin 0.152.0 → 0.154.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.mjs +22 -7
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -94,6 +94,12 @@ function hasDelegatedStyles(compiled) {
|
|
|
94
94
|
function supportsTemplateOnlyHmr(output) {
|
|
95
95
|
return /(?:^|\n)(?:_sfc_main|__sfc__)\.render\s*=\s*render\b/m.test(output);
|
|
96
96
|
}
|
|
97
|
+
function insertAfterStaticImports(output, imports) {
|
|
98
|
+
let insertAt = 0;
|
|
99
|
+
for (const match of output.matchAll(/^import\b[^\n]*(?:\r?\n|$)/gm)) insertAt = (match.index ?? 0) + match[0].length;
|
|
100
|
+
if (insertAt === 0) return `${imports}\n${output}`;
|
|
101
|
+
return `${output.slice(0, insertAt)}${imports}\n${output.slice(insertAt)}`;
|
|
102
|
+
}
|
|
97
103
|
function generateScopeId(filename) {
|
|
98
104
|
return createHash("sha256").update(filename).digest("hex").slice(0, 8);
|
|
99
105
|
}
|
|
@@ -153,7 +159,7 @@ function generateOutput(compiled, options) {
|
|
|
153
159
|
}
|
|
154
160
|
}
|
|
155
161
|
const allImports = [...styleImports, ...cssModuleImports].join("\n");
|
|
156
|
-
if (allImports) output = allImports
|
|
162
|
+
if (allImports) output = insertAfterStaticImports(output, allImports);
|
|
157
163
|
if (cssModuleImports.length > 0) {
|
|
158
164
|
const moduleBindings = [];
|
|
159
165
|
for (const block of compiled.styles) if (isCssModule(block)) {
|
|
@@ -566,10 +572,13 @@ const vueResolvableFromRootCache = /* @__PURE__ */ new Map();
|
|
|
566
572
|
function isVueResolvableFromRoot(root) {
|
|
567
573
|
let cached = vueResolvableFromRootCache.get(root);
|
|
568
574
|
if (cached === void 0) {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
575
|
+
const rootNodeModules = path.join(root, "node_modules");
|
|
576
|
+
const directPackageJson = path.join(rootNodeModules, "vue", "package.json");
|
|
577
|
+
cached = fs.existsSync(directPackageJson);
|
|
578
|
+
if (!cached) try {
|
|
579
|
+
const resolved = createRequire(path.join(root, "__vize_probe__.js")).resolve("vue/package.json");
|
|
580
|
+
const relative = path.relative(rootNodeModules, resolved);
|
|
581
|
+
cached = relative !== "" && !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
573
582
|
} catch {}
|
|
574
583
|
vueResolvableFromRootCache.set(root, cached);
|
|
575
584
|
}
|
|
@@ -960,7 +969,8 @@ function loadHook(state, id, loadOptions) {
|
|
|
960
969
|
if (id.startsWith("\0") && id.includes("?vue")) styleId = id.slice(1).replace(/\.module\.\w+$/, "").replace(/\.\w+$/, "");
|
|
961
970
|
const styleRequest = classifyVitePluginRequest(styleId);
|
|
962
971
|
if (styleRequest.isVueStyleQuery) {
|
|
963
|
-
const
|
|
972
|
+
const sourceRequest = classifyVitePluginRequest(styleRequest.path);
|
|
973
|
+
const realPath = sourceRequest.vizeVirtualPath ?? sourceRequest.normalizedFsId ?? sourceRequest.normalizedVuePath ?? styleRequest.path;
|
|
964
974
|
const lang = styleRequest.styleLang ?? null;
|
|
965
975
|
const scoped = styleRequest.styleScoped ?? null;
|
|
966
976
|
const fallbackCompiled = state.cache.get(realPath) ?? state.ssrCache.get(realPath);
|
|
@@ -1285,9 +1295,14 @@ function patchCssModuleGenerateScopedName(userConfig) {
|
|
|
1285
1295
|
if (!cssModules || typeof cssModules.generateScopedName !== "function") return;
|
|
1286
1296
|
const origFn = cssModules.generateScopedName;
|
|
1287
1297
|
cssModules.generateScopedName = function(name, filename, css) {
|
|
1288
|
-
return origFn.call(this, name,
|
|
1298
|
+
return origFn.call(this, name, normalizeCssModuleFilename(filename), css);
|
|
1289
1299
|
};
|
|
1290
1300
|
}
|
|
1301
|
+
function normalizeCssModuleFilename(filename) {
|
|
1302
|
+
const normalized = normalizeViteCssModuleFilename(filename);
|
|
1303
|
+
if (normalized.startsWith("/@fs/")) return normalized.slice(4);
|
|
1304
|
+
return normalized;
|
|
1305
|
+
}
|
|
1291
1306
|
//#endregion
|
|
1292
1307
|
//#region src/plugin/dev-middleware.ts
|
|
1293
1308
|
function installVirtualAssetMiddleware(devServer, state) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.154.0",
|
|
4
4
|
"description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@vizejs/native": "0.
|
|
42
|
+
"@vizejs/native": "0.154.0",
|
|
43
43
|
"tinyglobby": "0.2.16",
|
|
44
|
-
"vize": "0.
|
|
44
|
+
"vize": "0.154.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/node": "25.7.0",
|