@vizejs/vite-plugin 0.443.0 → 0.457.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/config-CniehWXB.mjs +259 -0
- package/dist/index.d.mts +7 -3
- package/dist/index.mjs +4 -3
- package/dist/internal/config-bridge.d.mts +1 -1
- package/dist/internal/vite-plus-task.mjs +1 -1
- package/dist/{plugin-BtoQBp_k.mjs → plugin-CHZJDKpS.mjs} +96 -130
- package/dist/plugin-VmflBZfL.mjs +2 -0
- package/dist/{runner-BewZHurL.mjs → runner-Eg2DQhNT.mjs} +1 -1
- package/dist/shared-config-BGZnoNvi.mjs +177 -0
- package/dist/{types-FAVNKGwf.d.mts → types-Di46SPcH.d.mts} +24 -4
- package/dist/vite-plus.d.mts +6 -2
- package/dist/vite-plus.mjs +66 -17
- package/package.json +4 -4
- package/dist/config-PP6EAmWc.mjs +0 -39
- package/dist/plugin-vVIKbM_1.mjs +0 -2
- package/dist/shared-config-dMxrrTkb.mjs +0 -69
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
1
|
+
import { a as isLegacyVueVersion, c as rewriteDynamicTemplateImports, d as shouldApplyDefineInVirtualModule, i as isLegacyVueCompatibilityMode, l as rewriteImportMetaGlobBase, n as resolveSharedConfig, o as applyDefineReplacements, r as createLegacyVueCompatibilityPlugin, s as createLogger, u as rewriteStaticAssetUrls } from "./shared-config-BGZnoNvi.mjs";
|
|
2
|
+
import { o as vizeConfigStore } from "./config-CniehWXB.mjs";
|
|
3
3
|
import { n as registerResolvedVizeConfig, r as unregisterResolvedVizeConfig } from "./config-bridge-Dv6U7_RC.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import crypto, { createHash } from "node:crypto";
|
|
6
6
|
import * as native from "@vizejs/native";
|
|
7
|
-
import {
|
|
7
|
+
import { buildInspectorGraph, chunkVitePrecompileFiles, classifyVitePluginRequest, createViteBareImportBases, createViteBareImportCandidates, createViteVirtualId, detectViteHmrUpdateType, diffVitePrecompileFiles, generateViteHmrCode, hasViteHmrChanges, isViteBareSpecifier, normalizeViteCssModuleFilename, normalizeViteDevMiddlewareUrl, normalizeVitePrecompileBatchSize, normalizeViteRequireBase, normalizeViteResolvedVuePath, resolveViteAliasRequest, resolveViteCssImports, resolveViteRelativeImport, resolveViteVuePath, scopeViteCssForPipeline, splitViteIdQuery, toViteBrowserImportPrefix, transformViteCssVarsForPipeline } from "@vizejs/native";
|
|
8
8
|
import { parseSync } from "oxc-parser";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import fs from "node:fs";
|
|
@@ -39,6 +39,15 @@ function detectHmrUpdateType(prev, next) {
|
|
|
39
39
|
function generateHmrCode(scopeId, updateType) {
|
|
40
40
|
return generateViteHmrCode(scopeId, updateType);
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Whether any style block changed between two compilations, regardless of the
|
|
44
|
+
* update type. A save that edits both the template and a style reports
|
|
45
|
+
* "template-only", but the style modules still have to be refreshed.
|
|
46
|
+
*/
|
|
47
|
+
function hasStyleChanges(prev, next) {
|
|
48
|
+
if (!prev) return true;
|
|
49
|
+
return prev.styleHash !== next.styleHash || styleFingerprint(prev) !== styleFingerprint(next);
|
|
50
|
+
}
|
|
42
51
|
function toHmrHashes(module) {
|
|
43
52
|
return module ? {
|
|
44
53
|
scriptHash: module.scriptHash,
|
|
@@ -413,10 +422,12 @@ function createStyleVirtualId(id) {
|
|
|
413
422
|
/** Recover the authored SFC before native classification and cache lookup. */
|
|
414
423
|
function normalizeStyleVirtualId(id) {
|
|
415
424
|
const withoutPrefix = id.startsWith("\0") ? id.slice(1) : id;
|
|
416
|
-
if (!withoutPrefix.includes("?vue")) return id;
|
|
417
425
|
const start = withoutPrefix.indexOf("?");
|
|
426
|
+
if (start < 0) return id;
|
|
418
427
|
const query = withoutPrefix.slice(start + 1);
|
|
419
|
-
const
|
|
428
|
+
const params = new URLSearchParams(query);
|
|
429
|
+
if (!params.has("vue")) return id;
|
|
430
|
+
const source = params.get("vize-file");
|
|
420
431
|
if (source && withoutPrefix.slice(0, start).includes(STYLE_MARKER)) return `${source}?${query}`;
|
|
421
432
|
return withoutPrefix.replace(/\.module\.\w+$/, "").replace(/\.\w+$/, "");
|
|
422
433
|
}
|
|
@@ -425,8 +436,8 @@ function normalizeStyleVirtualId(id) {
|
|
|
425
436
|
function scopeCssForPipeline(css, scopeId) {
|
|
426
437
|
return scopeViteCssForPipeline(css, scopeId);
|
|
427
438
|
}
|
|
428
|
-
function transformCssVarsForPipeline(css, scopeId) {
|
|
429
|
-
return transformViteCssVarsForPipeline(css, scopeId);
|
|
439
|
+
function transformCssVarsForPipeline(css, scopeId, productionFilename) {
|
|
440
|
+
return transformViteCssVarsForPipeline(css, scopeId, productionFilename);
|
|
430
441
|
}
|
|
431
442
|
/**
|
|
432
443
|
* Resolve CSS @import statements by inlining the imported files,
|
|
@@ -609,13 +620,14 @@ function generateScopeId(filename) {
|
|
|
609
620
|
/**
|
|
610
621
|
* Whether the SFC's `<style>` blocks are handed to Vite as virtual imports.
|
|
611
622
|
*
|
|
612
|
-
* Every
|
|
613
|
-
*
|
|
614
|
-
*
|
|
623
|
+
* Every SFC style block goes through Vite's CSS pipeline. SSR imports retain
|
|
624
|
+
* the dependency edges used by frameworks to discover styles in module order;
|
|
625
|
+
* omitting plain CSS there can change the cascade after hydration. The user's
|
|
626
|
+
* CSS transformer and targets also apply during development and tests.
|
|
615
627
|
* `compiled.css` remains a fallback for callers without block metadata.
|
|
616
628
|
*/
|
|
617
629
|
function usesStyleImports(compiled, options) {
|
|
618
|
-
return !!options.filePath && !!compiled.styles?.length
|
|
630
|
+
return !!options.filePath && !!compiled.styles?.length;
|
|
619
631
|
}
|
|
620
632
|
/**
|
|
621
633
|
* Whether `generateOutput` will embed `compiled.css` in the module.
|
|
@@ -628,8 +640,8 @@ function usesStyleImports(compiled, options) {
|
|
|
628
640
|
*
|
|
629
641
|
* That guard matters because resolving `@import`s reads and inlines files and
|
|
630
642
|
* crosses the native boundary with the whole stylesheet. A production client
|
|
631
|
-
* build
|
|
632
|
-
*
|
|
643
|
+
* build and an SSR build hand `<style>` blocks to Vite as virtual imports, so
|
|
644
|
+
* in both cases the resolved text was previously built
|
|
633
645
|
* and discarded, once per styled SFC on every build (270 discarded calls on the
|
|
634
646
|
* 300-file bench corpus).
|
|
635
647
|
*/
|
|
@@ -773,55 +785,6 @@ function toBrowserImportPrefix(replacement) {
|
|
|
773
785
|
return toViteBrowserImportPrefix(replacement);
|
|
774
786
|
}
|
|
775
787
|
//#endregion
|
|
776
|
-
//#region src/transform.ts
|
|
777
|
-
/**
|
|
778
|
-
* Code transformation utilities for Vize.
|
|
779
|
-
*
|
|
780
|
-
* Handles static asset URL rewriting, Vite define replacements, and
|
|
781
|
-
* provides the debug logger.
|
|
782
|
-
*/
|
|
783
|
-
/**
|
|
784
|
-
* Rewrite static asset URLs in compiled template output.
|
|
785
|
-
*
|
|
786
|
-
* Transforms property values like `src: "@/assets/logo.svg"` into import
|
|
787
|
-
* statements hoisted to the top of the module, so Vite's module resolution
|
|
788
|
-
* pipeline handles alias expansion and asset hashing in both dev and build.
|
|
789
|
-
*/
|
|
790
|
-
function rewriteStaticAssetUrls(code, aliasRules) {
|
|
791
|
-
if (aliasRules.length === 0 || !code.includes("src")) return code;
|
|
792
|
-
return rewriteViteStaticAssetUrls(code, aliasRules);
|
|
793
|
-
}
|
|
794
|
-
function rewriteDynamicTemplateImports(code, aliasRules) {
|
|
795
|
-
if (!code.includes("import(") || !code.includes("`")) return code;
|
|
796
|
-
return rewriteViteDynamicTemplateImports(code, aliasRules);
|
|
797
|
-
}
|
|
798
|
-
function rewriteImportMetaGlobBase(code, importer, root) {
|
|
799
|
-
if (!code.includes("import.meta.glob")) return code;
|
|
800
|
-
return rewriteViteImportMetaGlobBase(code, importer, root);
|
|
801
|
-
}
|
|
802
|
-
function shouldApplyDefineInVirtualModule(key) {
|
|
803
|
-
return shouldApplyViteDefineInVirtualModule(key);
|
|
804
|
-
}
|
|
805
|
-
/**
|
|
806
|
-
* Apply Vite define replacements to code.
|
|
807
|
-
* Replaces keys like `import.meta.vfFeatures.photoSection` with their values.
|
|
808
|
-
* Uses word-boundary-aware matching to avoid replacing inside strings or partial matches.
|
|
809
|
-
*/
|
|
810
|
-
function applyDefineReplacements(code, defines) {
|
|
811
|
-
return applyViteDefineReplacements(code, Object.entries(defines).map(([key, value]) => ({
|
|
812
|
-
key,
|
|
813
|
-
value
|
|
814
|
-
})));
|
|
815
|
-
}
|
|
816
|
-
function createLogger(debug) {
|
|
817
|
-
return {
|
|
818
|
-
log: (...args) => debug && console.log("[vize]", ...args),
|
|
819
|
-
info: (...args) => console.log("[vize]", ...args),
|
|
820
|
-
warn: (...args) => console.warn("[vize]", ...args),
|
|
821
|
-
error: (...args) => console.error("[vize]", ...args)
|
|
822
|
-
};
|
|
823
|
-
}
|
|
824
|
-
//#endregion
|
|
825
788
|
//#region src/plugin/plugin-vue-options.ts
|
|
826
789
|
const PLUGIN_VUE_COMPAT_VERSION = "6.0.7";
|
|
827
790
|
const DEFAULT_CUSTOM_ELEMENT_PATTERN = /\.ce\.vue$/;
|
|
@@ -1306,38 +1269,36 @@ function stableStringify(value) {
|
|
|
1306
1269
|
if (typeof value === "object" && value !== null) return `{${Object.entries(value).filter(([, item]) => item !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, item]) => `${JSON.stringify(key)}:${stableStringify(item)}`).join(",")}}`;
|
|
1307
1270
|
return JSON.stringify(value) ?? "null";
|
|
1308
1271
|
}
|
|
1309
|
-
|
|
1310
|
-
try {
|
|
1311
|
-
const stat = fs.statSync(binary);
|
|
1312
|
-
return `${path.basename(binary)}:${stat.size}:${stat.mtimeMs}`;
|
|
1313
|
-
} catch {
|
|
1314
|
-
return `${path.basename(binary)}:unresolved`;
|
|
1315
|
-
}
|
|
1316
|
-
}
|
|
1272
|
+
const unresolvedCompilerNonce = crypto.randomUUID();
|
|
1317
1273
|
/**
|
|
1318
1274
|
* Identity of the native compiler that produced (or would produce) the output.
|
|
1319
1275
|
*
|
|
1320
|
-
* The
|
|
1321
|
-
*
|
|
1322
|
-
*
|
|
1323
|
-
*
|
|
1324
|
-
* new identity — a miss, never a stale hit.
|
|
1276
|
+
* The successful loader reads the linked image's token once, including pnpm
|
|
1277
|
+
* siblings and path/universal fallbacks. OS image reuse or file replacement
|
|
1278
|
+
* cannot relabel code already in memory. Unknown providers get a process namespace,
|
|
1279
|
+
* so an old wrapper or unknown backend cannot reuse another process's output.
|
|
1325
1280
|
*/
|
|
1326
1281
|
function resolveCompilerIdentity() {
|
|
1327
|
-
const configured = process.env.NAPI_RS_NATIVE_LIBRARY_PATH;
|
|
1328
1282
|
try {
|
|
1329
|
-
const
|
|
1330
|
-
const
|
|
1283
|
+
const requireNative = createRequire(import.meta.url);
|
|
1284
|
+
const manifestPath = requireNative.resolve("@vizejs/native/package.json");
|
|
1331
1285
|
const version = JSON.parse(fs.readFileSync(manifestPath, "utf-8")).version;
|
|
1332
|
-
const
|
|
1286
|
+
const { getBindingIdentity } = requireNative("@vizejs/native/native-binding-identity.js");
|
|
1287
|
+
const identity = getBindingIdentity(requireNative("@vizejs/native"));
|
|
1333
1288
|
return {
|
|
1334
1289
|
version: typeof version === "string" ? version : "unknown",
|
|
1335
|
-
|
|
1290
|
+
binding: identity.kind === "native" ? {
|
|
1291
|
+
kind: identity.kind,
|
|
1292
|
+
token: identity.token
|
|
1293
|
+
} : identity
|
|
1336
1294
|
};
|
|
1337
1295
|
} catch {
|
|
1338
1296
|
return {
|
|
1339
1297
|
version: "unresolved",
|
|
1340
|
-
|
|
1298
|
+
binding: {
|
|
1299
|
+
kind: "process",
|
|
1300
|
+
nonce: unresolvedCompilerNonce
|
|
1301
|
+
}
|
|
1341
1302
|
};
|
|
1342
1303
|
}
|
|
1343
1304
|
}
|
|
@@ -2088,6 +2049,21 @@ async function resolveRelativeVueSfcImport(ctx, state, id, cleanImporter, isSsrR
|
|
|
2088
2049
|
return isDependencyScan ? resolvedPath : toPluginVisibleVirtualId(resolvedPath, isSsrRequest, effectiveQuery);
|
|
2089
2050
|
}
|
|
2090
2051
|
//#endregion
|
|
2052
|
+
//#region src/plugin/resolve-optimized-vue.ts
|
|
2053
|
+
function isOptimizedVueDependency(state, id) {
|
|
2054
|
+
const { request } = splitViteIdQuery(id);
|
|
2055
|
+
const normalized = request.split(path.sep).join("/");
|
|
2056
|
+
const cacheDir = state.viteCacheDir?.split(path.sep).join("/").replace(/\/+$/, "");
|
|
2057
|
+
if (cacheDir) {
|
|
2058
|
+
const prefix = `${cacheDir}/deps`;
|
|
2059
|
+
if (normalized.startsWith(prefix)) {
|
|
2060
|
+
const rest = normalized.slice(prefix.length);
|
|
2061
|
+
return /^(?:_[^/]*)?\/vue\./.test(rest);
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
return normalized.includes("/node_modules/.vite/deps/vue.");
|
|
2065
|
+
}
|
|
2066
|
+
//#endregion
|
|
2091
2067
|
//#region src/plugin/tree-shaking.ts
|
|
2092
2068
|
/** Template-only client output has no authored top-level script effects. */
|
|
2093
2069
|
function isPureTemplateOnlyModule(compiled) {
|
|
@@ -2369,10 +2345,6 @@ function resolveProjectNuxtVuePeerRuntimeEntryWithNode(state, id) {
|
|
|
2369
2345
|
const nuxtPackageRoot = path.dirname(splitViteIdQuery(nuxtPackageJson).request);
|
|
2370
2346
|
return resolveVuePeerRuntimeEntryFromBaseWithNode(id, path.join(state.root, "package.json")) ?? resolveVuePeerRuntimeEntryFromBaseWithNode(id, path.join(nuxtPackageRoot, "package.json"));
|
|
2371
2347
|
}
|
|
2372
|
-
function isOptimizedVueDependency(id) {
|
|
2373
|
-
const { request } = splitViteIdQuery(id);
|
|
2374
|
-
return request.split(path.sep).join("/").includes("/node_modules/.vite/deps/vue.");
|
|
2375
|
-
}
|
|
2376
2348
|
const vueResolvableFromRootCache = /* @__PURE__ */ new Map();
|
|
2377
2349
|
function isVueResolvableFromRoot(root) {
|
|
2378
2350
|
let cached = vueResolvableFromRootCache.get(root);
|
|
@@ -2417,7 +2389,7 @@ async function resolveProjectVueRuntime(ctx, state, id, importer, isSsrRequest)
|
|
|
2417
2389
|
}
|
|
2418
2390
|
try {
|
|
2419
2391
|
const resolved = await resolveWithVite(ctx, state, id, viteImporter, { skipSelf: true });
|
|
2420
|
-
if (resolved && isOptimizedVueDependency(resolved.id)) return null;
|
|
2392
|
+
if (resolved && isOptimizedVueDependency(state, resolved.id)) return null;
|
|
2421
2393
|
if (resolved) {
|
|
2422
2394
|
const projectLocalEntry = resolveProjectLocalPnpmVueRuntime(state, resolved.id);
|
|
2423
2395
|
if (projectLocalEntry) {
|
|
@@ -2614,7 +2586,7 @@ async function resolveIdHook(ctx, state, id, importer, options) {
|
|
|
2614
2586
|
...resolved,
|
|
2615
2587
|
id: normalizedFsId
|
|
2616
2588
|
};
|
|
2617
|
-
if (isVueRuntime && state.server !== null && !isOptimizedVueDependency(resolved.id)) {
|
|
2589
|
+
if (isVueRuntime && state.server !== null && !isOptimizedVueDependency(state, resolved.id)) {
|
|
2618
2590
|
const pnpmHoistedEntry = resolveVueBundlerEntryFromPnpmHoist(state, id, cleanImporter);
|
|
2619
2591
|
if (pnpmHoistedEntry) {
|
|
2620
2592
|
state.logger.log(`resolveId: resolved pnpm-hoisted Vue runtime to ${pnpmHoistedEntry}`);
|
|
@@ -2986,6 +2958,11 @@ function getCompiledStyleSource(state, realPath, ssr) {
|
|
|
2986
2958
|
if (compiled || !shouldLoadCompiledVueSfcPath(state, realPath) || !fs.existsSync(realPath)) return compiled;
|
|
2987
2959
|
return compileFile(realPath, cache, getCompileOptionsForRequest(state, ssr, realPath));
|
|
2988
2960
|
}
|
|
2961
|
+
function getVirtualStyleContent(block, options) {
|
|
2962
|
+
let styleContent = options.trim === false ? block.content : block.content.trim();
|
|
2963
|
+
if (options.scoped && block.scoped && (!options.lang || options.lang === "css")) styleContent = scopeCssForPipeline(styleContent, options.scoped);
|
|
2964
|
+
return transformCssVarsForPipeline(styleContent, options.scopeId, options.productionFilename);
|
|
2965
|
+
}
|
|
2989
2966
|
//#endregion
|
|
2990
2967
|
//#region src/plugin/load.ts
|
|
2991
2968
|
const SERVER_PLACEHOLDER_CODE = `import { createElementBlock, defineComponent } from "vue";
|
|
@@ -3096,11 +3073,14 @@ function loadHook(state, id, loadOptions) {
|
|
|
3096
3073
|
const blockIndex = styleRequest.styleIndex ?? -1;
|
|
3097
3074
|
if (fallbackCompiled?.styles && blockIndex >= 0 && blockIndex < fallbackCompiled.styles.length) {
|
|
3098
3075
|
const block = fallbackCompiled.styles[blockIndex];
|
|
3099
|
-
let styleContent = state.mergedOptions.style?.trim === false ? block.content : block.content.trim();
|
|
3100
|
-
if (scoped && block.scoped && (!lang || lang === "css")) styleContent = scopeCssForPipeline(styleContent, scoped);
|
|
3101
|
-
styleContent = transformCssVarsForPipeline(styleContent, fallbackCompiled.scopeId);
|
|
3102
3076
|
return {
|
|
3103
|
-
code:
|
|
3077
|
+
code: getVirtualStyleContent(block, {
|
|
3078
|
+
scopeId: fallbackCompiled.scopeId,
|
|
3079
|
+
scoped,
|
|
3080
|
+
lang,
|
|
3081
|
+
trim: state.mergedOptions.style?.trim,
|
|
3082
|
+
productionFilename: state.isProduction ? realPath : void 0
|
|
3083
|
+
}),
|
|
3104
3084
|
map: null
|
|
3105
3085
|
};
|
|
3106
3086
|
}
|
|
@@ -3352,18 +3332,7 @@ async function handleHotUpdateHook(state, ctx, options = {}) {
|
|
|
3352
3332
|
return [];
|
|
3353
3333
|
}
|
|
3354
3334
|
if (newCompiled.styles?.length && updateType === "style-only") {
|
|
3355
|
-
const affectedModules =
|
|
3356
|
-
for (const block of newCompiled.styles ?? []) {
|
|
3357
|
-
const params = new URLSearchParams();
|
|
3358
|
-
params.set("vue", "");
|
|
3359
|
-
params.set("type", "style");
|
|
3360
|
-
params.set("index", String(block.index));
|
|
3361
|
-
if (block.scoped) params.set("scoped", `data-v-${newCompiled.scopeId}`);
|
|
3362
|
-
params.set("lang", block.lang ?? "css");
|
|
3363
|
-
if (block.module !== false) params.set("module", typeof block.module === "string" ? block.module : "");
|
|
3364
|
-
const styleMods = await collectModulesByFile(server, getStyleModuleFileCandidates(`${file}?${params.toString()}`));
|
|
3365
|
-
for (const mod of styleMods) affectedModules.add(mod);
|
|
3366
|
-
}
|
|
3335
|
+
const affectedModules = await collectStyleModules(server, file, newCompiled);
|
|
3367
3336
|
if (affectedModules.size > 0) return [...affectedModules];
|
|
3368
3337
|
if (modules.size > 0) return [...modules];
|
|
3369
3338
|
return [];
|
|
@@ -3384,6 +3353,11 @@ async function handleHotUpdateHook(state, ctx, options = {}) {
|
|
|
3384
3353
|
if (modules.size > 0) {
|
|
3385
3354
|
state.pendingHmrUpdateTypes.set(file, updateType);
|
|
3386
3355
|
invalidateModules(server, modules);
|
|
3356
|
+
if (newCompiled.styles?.length && hasStyleChanges(prevCompiled, newCompiled)) {
|
|
3357
|
+
const styleModules = await collectStyleModules(server, file, newCompiled);
|
|
3358
|
+
invalidateModules(server, styleModules);
|
|
3359
|
+
return [...new Set([...modules, ...styleModules])];
|
|
3360
|
+
}
|
|
3387
3361
|
return [...modules];
|
|
3388
3362
|
}
|
|
3389
3363
|
state.pendingHmrUpdateTypes.delete(file);
|
|
@@ -3392,6 +3366,21 @@ async function handleHotUpdateHook(state, ctx, options = {}) {
|
|
|
3392
3366
|
options.onRecompileError?.(e);
|
|
3393
3367
|
}
|
|
3394
3368
|
}
|
|
3369
|
+
async function collectStyleModules(server, file, compiled) {
|
|
3370
|
+
const styleModules = /* @__PURE__ */ new Set();
|
|
3371
|
+
for (const block of compiled.styles ?? []) {
|
|
3372
|
+
const params = new URLSearchParams();
|
|
3373
|
+
params.set("vue", "");
|
|
3374
|
+
params.set("type", "style");
|
|
3375
|
+
params.set("index", String(block.index));
|
|
3376
|
+
if (block.scoped) params.set("scoped", `data-v-${compiled.scopeId}`);
|
|
3377
|
+
params.set("lang", block.lang ?? "css");
|
|
3378
|
+
if (block.module !== false) params.set("module", typeof block.module === "string" ? block.module : "");
|
|
3379
|
+
const styleId = `${file}?${params.toString()}`;
|
|
3380
|
+
for (const mod of await collectModulesByFile(server, getStyleModuleFileCandidates(styleId))) styleModules.add(mod);
|
|
3381
|
+
}
|
|
3382
|
+
return styleModules;
|
|
3383
|
+
}
|
|
3395
3384
|
function handleGenerateBundleHook(state, emitFile, bundle) {
|
|
3396
3385
|
if (!state.extractCss || state.collectedCss.size === 0) return;
|
|
3397
3386
|
let allCss = "";
|
|
@@ -3937,30 +3926,6 @@ function resolveExperimentalCompilerOptions(options, compilerConfig, config) {
|
|
|
3937
3926
|
};
|
|
3938
3927
|
}
|
|
3939
3928
|
//#endregion
|
|
3940
|
-
//#region src/plugin/vue-version.ts
|
|
3941
|
-
function isLegacyVueVersion(version) {
|
|
3942
|
-
return version === "legacy" || version === .11 || version === 1 || version === 2 || version === "2.7";
|
|
3943
|
-
}
|
|
3944
|
-
function isLegacyVueCompatibilityMode(options) {
|
|
3945
|
-
const vueVersion = options.vueVersion ?? options.compatibility?.vueVersion;
|
|
3946
|
-
return (options.compatibility?.hostCompiler ?? isLegacyVueVersion(vueVersion)) && isLegacyVueVersion(vueVersion);
|
|
3947
|
-
}
|
|
3948
|
-
function hasHostVueSfcCompilerPlugin(plugins) {
|
|
3949
|
-
return plugins.some((plugin) => {
|
|
3950
|
-
const name = plugin.name;
|
|
3951
|
-
return name === "vite:vue" || name === "vite:vue2" || name.includes("plugin-vue") || name.includes("vue2");
|
|
3952
|
-
});
|
|
3953
|
-
}
|
|
3954
|
-
function createLegacyVueCompatibilityPlugin(options) {
|
|
3955
|
-
return {
|
|
3956
|
-
name: "vite-plugin-vize:legacy-vue-compat",
|
|
3957
|
-
configResolved(resolvedConfig) {
|
|
3958
|
-
if (!hasHostVueSfcCompilerPlugin(resolvedConfig.plugins)) throw new Error("vite-plugin-vize: legacy Vue host-compiler mode requires a host Vue SFC compiler plugin. Add @vitejs/plugin-vue2 (or your framework's Vue 2 Vite SFC plugin), or set compatibility.hostCompiler=false if this project can use Vize's compiler pipeline.");
|
|
3959
|
-
createLogger(options.debug ?? false).log(`Legacy Vue compatibility mode is active for ${resolvedConfig.root}; Vize will not compile .vue files.`);
|
|
3960
|
-
}
|
|
3961
|
-
};
|
|
3962
|
-
}
|
|
3963
|
-
//#endregion
|
|
3964
3929
|
//#region src/plugin/index-helpers.ts
|
|
3965
3930
|
function shouldExtractCssForBuild(state, context) {
|
|
3966
3931
|
if (!state.isProduction) return false;
|
|
@@ -4195,7 +4160,7 @@ function resolveVueFeatureDefines(features, define) {
|
|
|
4195
4160
|
//#endregion
|
|
4196
4161
|
//#region src/plugin/index.ts
|
|
4197
4162
|
/** Framework-derived defaults yield to project, entry, and explicit plugin options. */
|
|
4198
|
-
function vize(options = {}, compilerDefaults = {}) {
|
|
4163
|
+
function vize(options = {}, compilerDefaults = {}, hostContext) {
|
|
4199
4164
|
if (isLegacyVueCompatibilityMode(options)) return [createLegacyVueCompatibilityPlugin(options)];
|
|
4200
4165
|
const state = {
|
|
4201
4166
|
cache: new CompiledModuleCache(),
|
|
@@ -4241,6 +4206,7 @@ function vize(options = {}, compilerDefaults = {}) {
|
|
|
4241
4206
|
},
|
|
4242
4207
|
async configResolved(resolvedConfig) {
|
|
4243
4208
|
state.root = options.root ?? resolvedConfig.root;
|
|
4209
|
+
state.viteCacheDir = resolvedConfig.cacheDir;
|
|
4244
4210
|
state.isProduction = options.isProduction ?? resolvedConfig.isProduction;
|
|
4245
4211
|
state.viteBuildSourcemap = !!resolvedConfig.build?.sourcemap;
|
|
4246
4212
|
const isSsrBuild = !!resolvedConfig.build?.ssr;
|
|
@@ -4263,7 +4229,7 @@ function vize(options = {}, compilerDefaults = {}) {
|
|
|
4263
4229
|
command: resolvedConfig.command === "build" ? "build" : "serve",
|
|
4264
4230
|
isSsrBuild: !!resolvedConfig.build?.ssr
|
|
4265
4231
|
};
|
|
4266
|
-
const sharedConfigPromise = resolveSharedConfig(options, state.root, configEnv, state.logger);
|
|
4232
|
+
const sharedConfigPromise = resolveSharedConfig(options, state.root, configEnv, state.logger, resolvedConfig, hostContext);
|
|
4267
4233
|
const sharedConfig = await register(resolvedConfig, state.root, sharedConfigPromise);
|
|
4268
4234
|
state.mergedOptions = mergeCompilerOptions(options, sharedConfig, compilerDefaults);
|
|
4269
4235
|
state.fileCompilerOptions = createFileCompilerOptions(sharedConfig, state.root, options, compilerDefaults);
|
|
@@ -4362,4 +4328,4 @@ function vize(options = {}, compilerDefaults = {}) {
|
|
|
4362
4328
|
];
|
|
4363
4329
|
}
|
|
4364
4330
|
//#endregion
|
|
4365
|
-
export {
|
|
4331
|
+
export { vize as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as resolveConfigExport, r as loadConfig } from "./config-
|
|
1
|
+
import { i as resolveConfigExport, r as loadConfig } from "./config-CniehWXB.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
4
|
import path from "node:path";
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { a as resolveViteConfigExport, i as resolveConfigExport, r as loadConfig } from "./config-CniehWXB.mjs";
|
|
2
|
+
import { applyViteDefineReplacements, rewriteViteDynamicTemplateImports, rewriteViteImportMetaGlobBase, rewriteViteStaticAssetUrls, shouldApplyViteDefineInVirtualModule } from "@vizejs/native";
|
|
3
|
+
//#region src/transform.ts
|
|
4
|
+
/**
|
|
5
|
+
* Code transformation utilities for Vize.
|
|
6
|
+
*
|
|
7
|
+
* Handles static asset URL rewriting, Vite define replacements, and
|
|
8
|
+
* provides the debug logger.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Rewrite static asset URLs in compiled template output.
|
|
12
|
+
*
|
|
13
|
+
* Transforms property values like `src: "@/assets/logo.svg"` into import
|
|
14
|
+
* statements hoisted to the top of the module, so Vite's module resolution
|
|
15
|
+
* pipeline handles alias expansion and asset hashing in both dev and build.
|
|
16
|
+
*/
|
|
17
|
+
function rewriteStaticAssetUrls(code, aliasRules) {
|
|
18
|
+
if (aliasRules.length === 0 || !code.includes("src")) return code;
|
|
19
|
+
return rewriteViteStaticAssetUrls(code, aliasRules);
|
|
20
|
+
}
|
|
21
|
+
function rewriteDynamicTemplateImports(code, aliasRules) {
|
|
22
|
+
if (!code.includes("import(") || !code.includes("`")) return code;
|
|
23
|
+
return rewriteViteDynamicTemplateImports(code, aliasRules);
|
|
24
|
+
}
|
|
25
|
+
function rewriteImportMetaGlobBase(code, importer, root) {
|
|
26
|
+
if (!code.includes("import.meta.glob")) return code;
|
|
27
|
+
return rewriteViteImportMetaGlobBase(code, importer, root);
|
|
28
|
+
}
|
|
29
|
+
function shouldApplyDefineInVirtualModule(key) {
|
|
30
|
+
return shouldApplyViteDefineInVirtualModule(key);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Apply Vite define replacements to code.
|
|
34
|
+
* Replaces keys like `import.meta.vfFeatures.photoSection` with their values.
|
|
35
|
+
* Uses word-boundary-aware matching to avoid replacing inside strings or partial matches.
|
|
36
|
+
*/
|
|
37
|
+
function applyDefineReplacements(code, defines) {
|
|
38
|
+
return applyViteDefineReplacements(code, Object.entries(defines).map(([key, value]) => ({
|
|
39
|
+
key,
|
|
40
|
+
value
|
|
41
|
+
})));
|
|
42
|
+
}
|
|
43
|
+
function createLogger(debug) {
|
|
44
|
+
return {
|
|
45
|
+
log: (...args) => debug && console.log("[vize]", ...args),
|
|
46
|
+
info: (...args) => console.log("[vize]", ...args),
|
|
47
|
+
warn: (...args) => console.warn("[vize]", ...args),
|
|
48
|
+
error: (...args) => console.error("[vize]", ...args)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/plugin/vue-version.ts
|
|
53
|
+
function isLegacyVueVersion(version) {
|
|
54
|
+
return version === "legacy" || version === .1 || version === .11 || version === 1 || version === 2 || version === "2.7";
|
|
55
|
+
}
|
|
56
|
+
function isLegacyVueCompatibilityMode(options) {
|
|
57
|
+
const vueVersion = options.vueVersion ?? options.compatibility?.vueVersion;
|
|
58
|
+
return (options.compatibility?.hostCompiler ?? isLegacyVueVersion(vueVersion)) && isLegacyVueVersion(vueVersion);
|
|
59
|
+
}
|
|
60
|
+
function hasHostVueSfcCompilerPlugin(plugins) {
|
|
61
|
+
return plugins.some((plugin) => {
|
|
62
|
+
const name = plugin.name;
|
|
63
|
+
return name === "vite:vue" || name === "vite:vue2" || name.includes("plugin-vue") || name.includes("vue2");
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function createLegacyVueCompatibilityPlugin(options) {
|
|
67
|
+
return {
|
|
68
|
+
name: "vite-plugin-vize:legacy-vue-compat",
|
|
69
|
+
configResolved(resolvedConfig) {
|
|
70
|
+
if (!hasHostVueSfcCompilerPlugin(resolvedConfig.plugins)) throw new Error("vite-plugin-vize: legacy Vue host-compiler mode requires a host Vue SFC compiler plugin. Add @vitejs/plugin-vue2 (or your framework's Vue 2 Vite SFC plugin), or set compatibility.hostCompiler=false if this project can use Vize's compiler pipeline.");
|
|
71
|
+
createLogger(options.debug ?? false).log(`Legacy Vue compatibility mode is active for ${resolvedConfig.root}; Vize will not compile .vue files.`);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/plugin/host-config-source.ts
|
|
77
|
+
const hostVueFields = new Set([
|
|
78
|
+
"isProduction",
|
|
79
|
+
"template",
|
|
80
|
+
"script",
|
|
81
|
+
"features"
|
|
82
|
+
]);
|
|
83
|
+
function nativeProjectSource(source, hostContext) {
|
|
84
|
+
if (hostContext !== "nuxt" || source === null || typeof source !== "object" || Array.isArray(source)) return source;
|
|
85
|
+
const descriptor = Object.getOwnPropertyDescriptor(source, "vue");
|
|
86
|
+
if (!descriptor) return source;
|
|
87
|
+
const host = source.vue;
|
|
88
|
+
let inspected = source;
|
|
89
|
+
if (!("value" in descriptor)) {
|
|
90
|
+
const captured = Object.getOwnPropertyDescriptors(source);
|
|
91
|
+
captured.vue = {
|
|
92
|
+
value: host,
|
|
93
|
+
enumerable: descriptor.enumerable,
|
|
94
|
+
configurable: descriptor.configurable,
|
|
95
|
+
writable: false
|
|
96
|
+
};
|
|
97
|
+
inspected = Object.create(Object.getPrototypeOf(source), captured);
|
|
98
|
+
}
|
|
99
|
+
if (host === null || typeof host !== "object") return inspected;
|
|
100
|
+
const prototype = Object.getPrototypeOf(host);
|
|
101
|
+
if (prototype !== Object.prototype && prototype !== null) return inspected;
|
|
102
|
+
const keys = Reflect.ownKeys(host);
|
|
103
|
+
if (!keys.length || !keys.every((key) => typeof key === "string" && hostVueFields.has(key))) return inspected;
|
|
104
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
105
|
+
delete descriptors.vue;
|
|
106
|
+
return Object.create(Object.getPrototypeOf(source), descriptors);
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/plugin/shared-config.ts
|
|
110
|
+
function mergeSharedConfig(baseConfig, overrideConfig) {
|
|
111
|
+
if (!baseConfig) return overrideConfig;
|
|
112
|
+
if (!overrideConfig) return baseConfig;
|
|
113
|
+
return {
|
|
114
|
+
...baseConfig,
|
|
115
|
+
...overrideConfig,
|
|
116
|
+
compiler: {
|
|
117
|
+
...baseConfig.compiler,
|
|
118
|
+
...overrideConfig.compiler
|
|
119
|
+
},
|
|
120
|
+
vite: {
|
|
121
|
+
...baseConfig.vite,
|
|
122
|
+
...overrideConfig.vite
|
|
123
|
+
},
|
|
124
|
+
linter: {
|
|
125
|
+
...baseConfig.linter,
|
|
126
|
+
...overrideConfig.linter
|
|
127
|
+
},
|
|
128
|
+
typeChecker: {
|
|
129
|
+
...baseConfig.typeChecker,
|
|
130
|
+
...overrideConfig.typeChecker
|
|
131
|
+
},
|
|
132
|
+
formatter: {
|
|
133
|
+
...baseConfig.formatter,
|
|
134
|
+
...overrideConfig.formatter
|
|
135
|
+
},
|
|
136
|
+
languageServer: {
|
|
137
|
+
...baseConfig.languageServer,
|
|
138
|
+
...overrideConfig.languageServer
|
|
139
|
+
},
|
|
140
|
+
musea: {
|
|
141
|
+
...baseConfig.musea,
|
|
142
|
+
...overrideConfig.musea
|
|
143
|
+
},
|
|
144
|
+
globalTypes: {
|
|
145
|
+
...baseConfig.globalTypes,
|
|
146
|
+
...overrideConfig.globalTypes
|
|
147
|
+
},
|
|
148
|
+
entries: [...baseConfig.entries, ...overrideConfig.entries]
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
async function resolveSharedConfig(options, root, env, logger, viteConfig, hostContext) {
|
|
152
|
+
let fileConfig = null;
|
|
153
|
+
if (options.configMode !== false) {
|
|
154
|
+
const configFile = options.configFile ?? process.env["VIZE_CONFIG_FILE"];
|
|
155
|
+
try {
|
|
156
|
+
fileConfig = await loadConfig(root, {
|
|
157
|
+
mode: options.configMode ?? "root",
|
|
158
|
+
configFile,
|
|
159
|
+
env,
|
|
160
|
+
viteConfig: false
|
|
161
|
+
});
|
|
162
|
+
if (fileConfig) logger.log("Loaded config from vize.config file");
|
|
163
|
+
} catch (error) {
|
|
164
|
+
logger.warn(`Failed to load vize config from ${configFile ?? root}:`, error);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
let inlineConfig = null;
|
|
168
|
+
if (options.config) try {
|
|
169
|
+
inlineConfig = await resolveConfigExport(options.config, env);
|
|
170
|
+
logger.log("Loaded inline vize config from plugin options");
|
|
171
|
+
} catch (error) {
|
|
172
|
+
logger.warn("Failed to resolve inline vize config:", error);
|
|
173
|
+
}
|
|
174
|
+
return mergeSharedConfig(mergeSharedConfig(viteConfig === void 0 || options.configMode === false ? null : await resolveViteConfigExport(nativeProjectSource(viteConfig, hostContext), env), fileConfig), inlineConfig);
|
|
175
|
+
}
|
|
176
|
+
//#endregion
|
|
177
|
+
export { isLegacyVueVersion as a, rewriteDynamicTemplateImports as c, shouldApplyDefineInVirtualModule as d, isLegacyVueCompatibilityMode as i, rewriteImportMetaGlobBase as l, resolveSharedConfig as n, applyDefineReplacements as o, createLegacyVueCompatibilityPlugin as r, createLogger as s, mergeSharedConfig as t, rewriteStaticAssetUrls as u };
|
|
@@ -90,7 +90,7 @@ interface CompilerConfig {
|
|
|
90
90
|
/**
|
|
91
91
|
* Vue template whitespace strategy or opt-in Vue 2 line-break migration mode
|
|
92
92
|
*/
|
|
93
|
-
whitespace?: "condense" | "preserve" | "vue2-line-breaks";
|
|
93
|
+
whitespace?: "condense" | "preserve" | "vue2-line-breaks" | "vue2-preserve";
|
|
94
94
|
/**
|
|
95
95
|
* Enable source map generation
|
|
96
96
|
*/
|
|
@@ -791,6 +791,7 @@ interface ConfigEnv {
|
|
|
791
791
|
mode: string;
|
|
792
792
|
command: "serve" | "build" | "check" | "lint" | "fmt";
|
|
793
793
|
isSsrBuild?: boolean;
|
|
794
|
+
isPreview?: boolean;
|
|
794
795
|
}
|
|
795
796
|
type VueConfig = {
|
|
796
797
|
/**
|
|
@@ -798,6 +799,15 @@ type VueConfig = {
|
|
|
798
799
|
*/
|
|
799
800
|
version?: VueVersion;
|
|
800
801
|
};
|
|
802
|
+
/** Native Vue settings shared by Vite, Vite+, the CLI projection and the editor. */
|
|
803
|
+
type VueOptionKeys = "compiler" | "typeChecker" | "linter" | "formatter" | "languageServer" | "globalTypes" | "files" | "ignores" | "basePath" | "lib";
|
|
804
|
+
/** Scoped policy currently supported by the native configuration model. */
|
|
805
|
+
type VueOptionsEntry = Pick<VizeConfigEntry, "basePath" | "files" | "ignores" | "linter">;
|
|
806
|
+
/** Section option values reuse the native types rather than a second schema. */
|
|
807
|
+
type VueOptions = Pick<VizeConfig, VueOptionKeys> & {
|
|
808
|
+
version?: VueVersion;
|
|
809
|
+
entries?: VueOptionsEntry[];
|
|
810
|
+
};
|
|
801
811
|
type UserConfigEntry = VizeConfigEntry & {
|
|
802
812
|
/**
|
|
803
813
|
* Shared Vue dialect section accepted by the Rust config model.
|
|
@@ -841,6 +851,8 @@ interface LoadConfigOptions {
|
|
|
841
851
|
* Custom config file path (overrides automatic search)
|
|
842
852
|
*/
|
|
843
853
|
configFile?: string;
|
|
854
|
+
/** Read Vite settings during discovery. Integrations with an already loaded Vite config use false. */
|
|
855
|
+
viteConfig?: boolean;
|
|
844
856
|
/**
|
|
845
857
|
* Config environment for dynamic config resolution
|
|
846
858
|
*/
|
|
@@ -935,7 +947,7 @@ interface ExperimentalPluginOptions extends ExperimentalCompileFlags {
|
|
|
935
947
|
}
|
|
936
948
|
//#endregion
|
|
937
949
|
//#region src/compatibility-types.d.ts
|
|
938
|
-
type VizeVueVersion = 0.11 | 1 | 2 | "2.7" | 3 | "legacy";
|
|
950
|
+
type VizeVueVersion = 0.1 | 0.11 | 1 | 2 | "2.7" | 3 | "legacy";
|
|
939
951
|
interface VizeCompatibilityOptions {
|
|
940
952
|
/**
|
|
941
953
|
* Host Vue version. Vue 0.11/1/2/2.7 opt into host-compiler compatibility.
|
|
@@ -1112,6 +1124,14 @@ interface CompiledModule {
|
|
|
1112
1124
|
}
|
|
1113
1125
|
//#endregion
|
|
1114
1126
|
//#region src/types.d.ts
|
|
1127
|
+
declare module "vite" {
|
|
1128
|
+
interface UserConfig {
|
|
1129
|
+
/** Native compiler, lint, format, checker, editor and Musea settings shared with the CLI. */
|
|
1130
|
+
vue?: VueOptions;
|
|
1131
|
+
/** Legacy native namespace; canonical Vue members take precedence. */
|
|
1132
|
+
vize?: UserConfigExport;
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1115
1135
|
interface VizeOptions extends ExperimentalPluginOptions {
|
|
1116
1136
|
/**
|
|
1117
1137
|
* Inline shared Vize config for Vite Plus-first projects.
|
|
@@ -1230,7 +1250,7 @@ interface VizeOptions extends ExperimentalPluginOptions {
|
|
|
1230
1250
|
*/
|
|
1231
1251
|
templateSyntax?: "standard" | "strict" | "quirks";
|
|
1232
1252
|
/** Vue whitespace strategy, or Vize's narrow Vue 2 line-break migration mode. @default "condense" */
|
|
1233
|
-
whitespace?: "condense" | "preserve" | "vue2-line-breaks";
|
|
1253
|
+
whitespace?: "condense" | "preserve" | "vue2-line-breaks" | "vue2-preserve";
|
|
1234
1254
|
/** Root directory to scan for .vue files; defaults to Vite's root. */
|
|
1235
1255
|
root?: string;
|
|
1236
1256
|
/** Framework manifest root; registers relative IDs, including external SFCs. */
|
|
@@ -1280,4 +1300,4 @@ interface VizeOptions extends ExperimentalPluginOptions {
|
|
|
1280
1300
|
debug?: boolean;
|
|
1281
1301
|
}
|
|
1282
1302
|
//#endregion
|
|
1283
|
-
export {
|
|
1303
|
+
export { CompilerConfig as _, VizeInspectorLintPlanProvider as a, TypeCheckerConfig as b, VizeCompatibilityOptions as c, LoadConfigOptions as d, ResolvedVizeConfig as f, VueOptionsEntry as g, VueOptions as h, VizeVueFeatures as i, VizeVueVersion as l, UserConfigExport as m, CompiledModule as n, VizeInspectorLintPlanRequest as o, UserConfig as p, MacroArtifact as r, VizeInspectorOptions as s, VizeOptions as t, ConfigEnv as u, FormatterConfig as v, VizeConfig as x, LinterConfig as y };
|