@vizejs/vite-plugin 0.429.0 → 0.429.2

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.
@@ -28,7 +28,15 @@ function recommendEditor(source, extensions) {
28
28
  };
29
29
  if (extensions) {
30
30
  if (parsed.recommendations !== void 0 && (!Array.isArray(parsed.recommendations) || !parsed.recommendations.every((value) => typeof value === "string"))) throw new Error("extensions.json recommendations must be a string array.");
31
- const merged = [...new Set([...parsed.recommendations ?? [], ...recommendations])];
31
+ const merged = [...parsed.recommendations ?? []];
32
+ const seen = new Set(merged.map((id) => id.toLowerCase()));
33
+ for (const recommendation of recommendations) {
34
+ const id = recommendation.toLowerCase();
35
+ if (!seen.has(id)) {
36
+ merged.push(recommendation);
37
+ seen.add(id);
38
+ }
39
+ }
32
40
  if (JSON.stringify(merged) !== JSON.stringify(parsed.recommendations)) set(["recommendations"], merged);
33
41
  } else for (const [keys, value] of defaults) if (keys.reduce((object, key) => object?.[key], parsed) === void 0) set(keys, value);
34
42
  return result;
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as VizeInspectorLintPlanProvider, c as VizeCompatibilityOptions, d as LoadConfigOptions, f as ResolvedVizeConfig, i as VizeVueFeatures, l as VizeVueVersion, m as UserConfigExport, n as CompiledModule, o as VizeInspectorLintPlanRequest, r as MacroArtifact, s as VizeInspectorOptions, t as VizeOptions, u as ConfigEnv, y as VizeConfig } from "./types-BSmJ5UMW.mjs";
1
+ import { a as VizeInspectorLintPlanProvider, c as VizeCompatibilityOptions, d as LoadConfigOptions, f as ResolvedVizeConfig, i as VizeVueFeatures, l as VizeVueVersion, m as UserConfigExport, n as CompiledModule, o as VizeInspectorLintPlanRequest, r as MacroArtifact, s as VizeInspectorOptions, t as VizeOptions, u as ConfigEnv, y as VizeConfig } from "./types-VGJL5xEW.mjs";
2
2
  import { Plugin } from "vite";
3
3
 
4
4
  //#region src/virtual.d.ts
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as rewriteStaticAssetUrls, t as vize } from "./plugin-46Af12dC.mjs";
1
+ import { n as rewriteStaticAssetUrls, t as vize } from "./plugin-Bu9B_IUr.mjs";
2
2
  import { a as vizeConfigStore, i as resolveConfigExport, n as defineConfig, r as loadConfig, t as VIZE_CONFIG_FILE_ENV } from "./config-PP6EAmWc.mjs";
3
3
  //#region src/index.ts
4
4
  const __internal = { rewriteStaticAssetUrls };
@@ -1,4 +1,4 @@
1
- import { f as ResolvedVizeConfig } from "../types-BSmJ5UMW.mjs";
1
+ import { f as ResolvedVizeConfig } from "../types-VGJL5xEW.mjs";
2
2
  import { ResolvedConfig } from "vite";
3
3
 
4
4
  //#region src/internal/config-bridge.d.ts
@@ -1,4 +1,4 @@
1
- import { n as runTask } from "../runner-8x__0QxE.mjs";
1
+ import { n as runTask } from "../runner-Tb17R9ol.mjs";
2
2
  //#region src/internal/vite-plus-task.ts
3
3
  try {
4
4
  process.exitCode = await runTask(process.argv.slice(2));
@@ -375,12 +375,12 @@ function createStyleVirtualId(id) {
375
375
  const start = id.indexOf("?");
376
376
  const filename = id.slice(0, start);
377
377
  const params = new URLSearchParams(id.slice(start + 1));
378
- if (params.has("vize-file") && filename.includes(STYLE_MARKER)) return id;
378
+ if (params.has("vize-file") && filename.includes(STYLE_MARKER)) return `${params.get("vize-file") ?? ""}${filename.slice(filename.lastIndexOf(STYLE_MARKER))}?${id.slice(start + 1).replaceAll(".", "%2E")}`;
379
379
  const index = params.get("index") ?? "0";
380
380
  const lang = params.get("lang") || "css";
381
381
  const suffix = params.has("module") ? `.module.${lang}` : `.${lang}`;
382
- const source = params.has("vize-file") ? "" : `&${new URLSearchParams({ "vize-file": filename }).toString()}`;
383
- return `${filename}${STYLE_MARKER}${index}${suffix}?${id.slice(start + 1)}${source}`;
382
+ const source = params.has("vize-file") ? "" : `&${new URLSearchParams({ "vize-file": filename }).toString().replaceAll(".", "%2E")}`;
383
+ return `${filename}${STYLE_MARKER}${index}${suffix}?${(id.slice(start + 1) + source).replaceAll(".", "%2E")}`;
384
384
  }
385
385
  /** Recover the authored SFC before native classification and cache lookup. */
386
386
  function normalizeStyleVirtualId(id) {
@@ -634,15 +634,11 @@ function generateOutputWithMap(compiled, options) {
634
634
  } else if (hasExportDefault && hasSfcMainDefined) {
635
635
  if (compiled.hasScoped && compiled.scopeId) emitted.edit(insertBeforeSfcMainDefaultExport(emitted.code, `_sfc_main.__scopeId = "data-v-${compiled.scopeId}";`, { moduleInfo }));
636
636
  } else if (!hasExportDefault && !hasSfcMainDefined && hasNamedRenderExport) {
637
- emitted.edit(`${emitted.code}\nconst _sfc_main = {};`);
638
- if (compiled.hasScoped && compiled.scopeId) emitted.edit(`${emitted.code}\n_sfc_main.__scopeId = "data-v-${compiled.scopeId}";`);
639
- emitted.edit(`${emitted.code}\n_sfc_main.render = render;`);
640
- emitted.edit(`${emitted.code}\nexport default _sfc_main;`);
637
+ const scope = compiled.hasScoped && compiled.scopeId ? `, __scopeId: "data-v-${compiled.scopeId}"` : "";
638
+ emitted.edit(`${emitted.code}\nconst _sfc_main = { render${scope} };\nexport default _sfc_main;`);
641
639
  } else if (!hasExportDefault && !hasSfcMainDefined && hasNamedSsrRenderExport) {
642
- emitted.edit(`${emitted.code}\nconst _sfc_main = {};`);
643
- if (compiled.hasScoped && compiled.scopeId) emitted.edit(`${emitted.code}\n_sfc_main.__scopeId = "data-v-${compiled.scopeId}";`);
644
- emitted.edit(`${emitted.code}\n_sfc_main.ssrRender = ssrRender;`);
645
- emitted.edit(`${emitted.code}\nexport default _sfc_main;`);
640
+ const scope = compiled.hasScoped && compiled.scopeId ? `, __scopeId: "data-v-${compiled.scopeId}"` : "";
641
+ emitted.edit(`${emitted.code}\nconst _sfc_main = { ssrRender${scope} };\nexport default _sfc_main;`);
646
642
  }
647
643
  if (usesStyleImports(compiled, options)) {
648
644
  const styleImports = [];
@@ -710,26 +706,26 @@ function isVizeSsrVirtual(id) {
710
706
  function toVirtualId(realPath, ssr = false) {
711
707
  return createViteVirtualId(realPath, ssr);
712
708
  }
713
- function toPluginVisibleVirtualId(realPath, ssr = false, querySuffix = "") {
709
+ function toPluginVisibleVirtualId(realPath, _ssr = false, querySuffix = "") {
714
710
  const params = new URLSearchParams(querySuffix.startsWith("?") ? querySuffix.slice(1) : "");
715
711
  params.delete("vue");
716
712
  params.delete("vize");
717
713
  params.delete("vize-ssr");
718
714
  const rest = params.toString();
719
- return `${realPath}.ts?vue&${ssr ? "vize-ssr" : "vize"}${rest ? `&${rest}` : ""}`;
715
+ return `${realPath}?vue&vize${rest ? `&${rest}` : ""}`;
720
716
  }
721
717
  /**
722
718
  * String pre-gate for {@link fromPluginVisibleVirtualId}, so ordinary module IDs
723
719
  * never cross the native boundary (#3427).
724
720
  *
725
- * A non-null result requires `request.path` to end with `.vue.ts` or `.vue.tsx`
721
+ * A non-null result requires `request.path` to end with `.vue`, `.vue.ts` or `.vue.tsx`
726
722
  * and `request.querySuffix` to be non-empty. `request.path` is `id` up to the
727
723
  * first `?` and `querySuffix` is non-empty exactly when that `?` exists, so both
728
724
  * conditions imply these two substring tests. The tests are strictly weaker, so
729
725
  * everything the old code accepted still reaches the classifier.
730
726
  */
731
727
  function mayBePluginVisibleVirtualId(id) {
732
- return !id.startsWith("\0") && id.includes(".vue.ts") && id.includes("?");
728
+ return !id.startsWith("\0") && id.includes(".vue") && id.includes("?");
733
729
  }
734
730
  function fromPluginVisibleVirtualId(id) {
735
731
  if (!mayBePluginVisibleVirtualId(id)) return null;
@@ -753,7 +749,7 @@ function stripFsPrefix(path) {
753
749
  return path.startsWith("/@fs") ? path.slice(4) : path;
754
750
  }
755
751
  function isPluginVisibleVueVirtualPath(path) {
756
- return path.endsWith(".vue.ts") || path.endsWith(".vue.tsx");
752
+ return path.endsWith(".vue") || path.endsWith(".vue.ts") || path.endsWith(".vue.tsx");
757
753
  }
758
754
  function stripPluginVisibleVueVirtualSuffix(path) {
759
755
  if (path.endsWith(".vue.tsx")) return path.slice(0, -4);
@@ -915,6 +911,10 @@ function getCompileOptionsForRequest(state, ssr) {
915
911
  if (state.mergedOptions?.experimentalSelfComponent) options.experimentalSelfComponent = true;
916
912
  if (state.mergedOptions?.experimentalStrictSlotChildren) options.experimentalStrictSlotChildren = true;
917
913
  if (state.mergedOptions?.experimentalServerScript) options.experimentalServerScript = true;
914
+ if (state.isProduction) {
915
+ options.isProd = true;
916
+ if (!ssr && options.mode !== "function") options.inlineTemplate = true;
917
+ }
918
918
  return options;
919
919
  }
920
920
  function syncCollectedCssForFile(state, filePath, compiled) {
@@ -1057,6 +1057,8 @@ function buildCompileFileOptions(filePath, options) {
1057
1057
  ...options.templateComments === void 0 ? {} : { templateComments: options.templateComments },
1058
1058
  ...options.templateHoistStatic === void 0 ? {} : { templateHoistStatic: options.templateHoistStatic },
1059
1059
  ...options.templatePrefixIdentifiers === void 0 ? {} : { templatePrefixIdentifiers: options.templatePrefixIdentifiers },
1060
+ ...options.inlineTemplate === void 0 ? {} : { inlineTemplate: options.inlineTemplate },
1061
+ ...options.isProd === void 0 ? {} : { isProd: options.isProd },
1060
1062
  ...options.mode === void 0 ? {} : { mode: options.mode },
1061
1063
  ...options.templateSyntax === void 0 ? {} : { templateSyntax: options.templateSyntax },
1062
1064
  ...options.runtimeModuleName === void 0 ? {} : { runtimeModuleName: options.runtimeModuleName },
@@ -1085,6 +1087,8 @@ function buildCompileBatchOptions(options) {
1085
1087
  ...options.templateComments === void 0 ? {} : { templateComments: options.templateComments },
1086
1088
  ...options.templateHoistStatic === void 0 ? {} : { templateHoistStatic: options.templateHoistStatic },
1087
1089
  ...options.templatePrefixIdentifiers === void 0 ? {} : { templatePrefixIdentifiers: options.templatePrefixIdentifiers },
1090
+ ...options.inlineTemplate === void 0 ? {} : { inlineTemplate: options.inlineTemplate },
1091
+ ...options.isProd === void 0 ? {} : { isProd: options.isProd },
1088
1092
  ...options.mode === void 0 ? {} : { mode: options.mode },
1089
1093
  ...options.templateSyntax === void 0 ? {} : { templateSyntax: options.templateSyntax },
1090
1094
  ...options.runtimeModuleName === void 0 ? {} : { runtimeModuleName: options.runtimeModuleName },
@@ -1331,7 +1335,7 @@ function resolveCompilerIdentity() {
1331
1335
  */
1332
1336
  function computePrecompileCacheKey(compileOptions) {
1333
1337
  const material = stableStringify({
1334
- format: 3,
1338
+ format: 4,
1335
1339
  compiler: resolveCompilerIdentity(),
1336
1340
  options: compileOptions
1337
1341
  });
@@ -1450,7 +1454,7 @@ function encodePrecompileManifest(options) {
1450
1454
  const indexBody = compressBody(Buffer.from(JSON.stringify(index), "utf8"));
1451
1455
  const payloadBody = compressBody(Buffer.concat(records));
1452
1456
  const header = Buffer.from(JSON.stringify({
1453
- format: 3,
1457
+ format: 4,
1454
1458
  key,
1455
1459
  codec: hasZstd ? "zstd" : "gzip",
1456
1460
  index: indexBody.length,
@@ -1526,7 +1530,7 @@ function decodePrecompileManifest(bytes, options) {
1526
1530
  return reject("unparsable header");
1527
1531
  }
1528
1532
  if (typeof header !== "object" || header === null || Array.isArray(header)) return reject("unrecognized header");
1529
- if (header.format !== 3 || header.key !== key) return reject("foreign format or key");
1533
+ if (header.format !== 4 || header.key !== key) return reject("foreign format or key");
1530
1534
  if (!isByteLength(header.index) || !isByteLength(header.payload)) return reject("unrecognized body lengths");
1531
1535
  const indexStart = headerEnd + 1;
1532
1536
  const payloadStart = indexStart + header.index;
@@ -1763,7 +1767,9 @@ function resolvePrecompileBatchOptions(state) {
1763
1767
  templateCacheHandlers: requestOptions.templateCacheHandlers,
1764
1768
  templateComments: requestOptions.templateComments,
1765
1769
  templateHoistStatic: requestOptions.templateHoistStatic,
1766
- templatePrefixIdentifiers: requestOptions.templatePrefixIdentifiers
1770
+ templatePrefixIdentifiers: requestOptions.templatePrefixIdentifiers,
1771
+ inlineTemplate: requestOptions.inlineTemplate,
1772
+ isProd: requestOptions.isProd
1767
1773
  };
1768
1774
  }
1769
1775
  function openCacheForRun(state, batchOptions) {
@@ -1878,7 +1884,8 @@ async function compileAll(state) {
1878
1884
  if (metadata) state.precompileMetadata.set(fileResult.path, metadata);
1879
1885
  const compiled = state.cache.get(fileResult.path);
1880
1886
  const sourceHash = sourceHashes.get(fileResult.path);
1881
- if (compiled && sourceHash !== void 0) cache.set(fileResult.path, sourceHash, compiled);
1887
+ if (fileResult.warnings.length > 0) cache.delete(fileResult.path);
1888
+ else if (compiled && sourceHash !== void 0) cache.set(fileResult.path, sourceHash, compiled);
1882
1889
  syncCollectedCssForFile({
1883
1890
  ...state,
1884
1891
  extractCss: state.extractCss && !isPluginVueCustomElement(state.mergedOptions, fileResult.path)
@@ -2060,6 +2067,27 @@ async function resolveRelativeVueSfcImport(ctx, state, id, cleanImporter, isSsrR
2060
2067
  return isDependencyScan ? resolvedPath : toPluginVisibleVirtualId(resolvedPath, isSsrRequest, effectiveQuery);
2061
2068
  }
2062
2069
  //#endregion
2070
+ //#region src/plugin/tree-shaking.ts
2071
+ /** Template-only client output has no authored top-level script effects. */
2072
+ function isPureTemplateOnlyModule(compiled) {
2073
+ const shape = compiled?.moduleShape;
2074
+ return !!(shape?.hasNamedRenderExport && !shape.hasDefaultExport && !shape.hasSfcMainDefined);
2075
+ }
2076
+ function resolveTemplateOnlySfcId(state, source, isSsr, querySuffix) {
2077
+ const id = toPluginVisibleVirtualId(source, isSsr, querySuffix);
2078
+ return state.isProduction && !isSsr && isPureTemplateOnlyModule(state.cache.get(source)) ? {
2079
+ id,
2080
+ moduleSideEffects: false
2081
+ } : id;
2082
+ }
2083
+ function loadedSfcModule(code, map, isProduction, isSsr, compiled) {
2084
+ return {
2085
+ code,
2086
+ map,
2087
+ ...isProduction && !isSsr && isPureTemplateOnlyModule(compiled) ? { moduleSideEffects: false } : {}
2088
+ };
2089
+ }
2090
+ //#endregion
2063
2091
  //#region src/plugin/resolve.ts
2064
2092
  function resolveVuePath(state, id, importer) {
2065
2093
  return resolveViteVuePath(state.root, id, importer);
@@ -2320,7 +2348,7 @@ function resolveProjectNuxtVuePeerRuntimeEntryWithNode(state, id) {
2320
2348
  if (!nuxtPackageJson) return null;
2321
2349
  const nuxtPackageRoot = path.dirname(splitViteIdQuery(nuxtPackageJson).request);
2322
2350
  if (!resolveProjectLocalResolvedPath(state, nuxtPackageRoot)) return null;
2323
- return resolveVuePeerRuntimeEntryFromBaseWithNode(state, id, path.join(nuxtPackageRoot, "package.json"));
2351
+ return resolveVuePeerRuntimeEntryFromBaseWithNode(state, id, path.join(state.root, "package.json")) ?? resolveVuePeerRuntimeEntryFromBaseWithNode(state, id, path.join(nuxtPackageRoot, "package.json"));
2324
2352
  }
2325
2353
  function isOptimizedVueDependency(id) {
2326
2354
  const { request } = splitViteIdQuery(id);
@@ -2393,7 +2421,7 @@ function nativeCssAliasRules(state) {
2393
2421
  return state.cssAliasRules.length === 0 ? EMPTY_NATIVE_ALIAS_RULES : state.cssAliasRules.map(toNativeCssAliasRule);
2394
2422
  }
2395
2423
  function isPotentialVizeResolveId(id) {
2396
- return id.startsWith("\0") || id.startsWith("vize:") || id.startsWith("/@fs") || isProjectVueRuntimeRequest(id) || id === "virtual:vize-styles" || id.endsWith(".vue") || id.includes(".vue?") || /\.vue\.tsx?\?/.test(id) || id.includes("?macro=true") || id.includes("?definePage");
2424
+ return id.startsWith("\0") || id.startsWith("vize:") || id.startsWith("/@fs") || isProjectVueRuntimeRequest(id) || id === "virtual:vize-styles" || id.endsWith(".vue") || /\.vue(?:\?|\.__vize_style_)/.test(id) || /\.vue\.tsx?\?/.test(id) || id.includes("?macro=true") || id.includes("?definePage");
2397
2425
  }
2398
2426
  function classifyImporterRequest(importer) {
2399
2427
  return importer ? classifyVitePluginRequest(importer) : null;
@@ -2709,7 +2737,8 @@ async function resolveIdHook(ctx, state, id, importer, options) {
2709
2737
  state.logger.log(`resolveId: id=${id}, resolved=${resolved}, hasCache=${hasCache}, fileExists=${fileExists}, importer=${importer ?? "none"}`);
2710
2738
  if (hasCache || fileExists) {
2711
2739
  if (preserveQueryAsPath) return `${resolved}${request.querySuffix}`;
2712
- return isDependencyScan ? resolved : toPluginVisibleVirtualId(resolved, isSsrRequest, request.querySuffix);
2740
+ if (isDependencyScan) return resolved;
2741
+ return resolveTemplateOnlySfcId(state, resolved, isSsrRequest, request.querySuffix);
2713
2742
  }
2714
2743
  }
2715
2744
  return null;
@@ -2780,8 +2809,8 @@ const SFC_MAIN_DECLARATION = /\b(?:const|let|var)\s+_sfc_main\s*=/;
2780
2809
  * The key must be the module's path relative to the Vite root with POSIX
2781
2810
  * separators, because that is what the client manifest is keyed on.
2782
2811
  */
2783
- function ssrModuleRegistrationCode(filePath, root, helpers = {}) {
2784
- const moduleId = JSON.stringify(toManifestModuleId(filePath, root));
2812
+ function ssrModuleRegistrationCode(filePath, root, helpers = {}, frameworkRoot) {
2813
+ const moduleId = JSON.stringify(frameworkRoot === void 0 ? toManifestModuleId(filePath, root) : path.relative(frameworkRoot, filePath).replace(/\\/g, "/"));
2785
2814
  const useSSRContext = helpers.useSSRContext ?? "__vize_useSSRContext";
2786
2815
  const sfcSetup = helpers.sfcSetup ?? "__vize_sfc_setup";
2787
2816
  return {
@@ -2825,13 +2854,13 @@ function toManifestModuleId(filePath, root) {
2825
2854
  * a boundary placeholder — have no component object to wrap and are returned
2826
2855
  * untouched.
2827
2856
  */
2828
- function appendSsrModuleRegistration(code, filePath, root, isSsr) {
2857
+ function appendSsrModuleRegistration(code, filePath, root, isSsr, frameworkRoot) {
2829
2858
  if (!isSsr || !SFC_MAIN_DECLARATION.test(code)) return code;
2830
2859
  if (code.includes(REGISTRATION_MARKER)) return code;
2831
2860
  const { prologue, epilogue } = ssrModuleRegistrationCode(filePath, root, {
2832
2861
  useSSRContext: freeIdentifier("__vize_useSSRContext", code),
2833
2862
  sfcSetup: freeIdentifier("__vize_sfc_setup", code)
2834
- });
2863
+ }, frameworkRoot);
2835
2864
  return `${prologue}\n${code}\n${epilogue}`;
2836
2865
  }
2837
2866
  /**
@@ -2847,6 +2876,10 @@ function freeIdentifier(base, code) {
2847
2876
  if (!new RegExp(`\\b${candidate}\\b`).test(code)) return candidate;
2848
2877
  }
2849
2878
  }
2879
+ /** Keep compiler/config root separate from Nuxt's source-relative manifest IDs. */
2880
+ function registerSfcModule(state, code, filePath, isSsr) {
2881
+ return appendSsrModuleRegistration(code, filePath, state.root, isSsr, state.mergedOptions.ssrModuleIdRoot);
2882
+ }
2850
2883
  //#endregion
2851
2884
  //#region src/plugin/vite-transform.ts
2852
2885
  function createVirtualTypeScriptTransformer(viteApi) {
@@ -2923,6 +2956,15 @@ async function transformVizeVirtualModule(state, code, realPath, ssr, forceTypeS
2923
2956
  }
2924
2957
  }
2925
2958
  //#endregion
2959
+ //#region src/plugin/load-style.ts
2960
+ /** Nuxt can load an emitted CSS entry before loading its owning SFC. */
2961
+ function getCompiledStyleSource(state, realPath, ssr) {
2962
+ const cache = getEnvironmentCache(state, ssr);
2963
+ const compiled = cache.get(realPath) ?? state.cache.get(realPath) ?? state.ssrCache.get(realPath);
2964
+ if (compiled || !shouldLoadCompiledVueSfcPath(state, realPath) || !fs.existsSync(realPath)) return compiled;
2965
+ return compileFile(realPath, cache, getCompileOptionsForRequest(state, ssr));
2966
+ }
2967
+ //#endregion
2926
2968
  //#region src/plugin/load.ts
2927
2969
  const SERVER_PLACEHOLDER_CODE = `import { createElementBlock, defineComponent } from "vue";
2928
2970
  export default defineComponent({
@@ -2995,11 +3037,8 @@ function loadCompiledSfcModule(state, realPath, isSsr, currentBase, loadOptions)
2995
3037
  rewritten.edit(rewriteDynamicTemplateImports(rewritten.code, state.dynamicImportAliasRules));
2996
3038
  rewritten.edit(rewriteStaticAssetUrls(rewritten.code, state.dynamicImportAliasRules));
2997
3039
  rewritten.edit(rewriteImportMetaGlobBase(rewritten.code, realPath, state.root));
2998
- rewritten.edit(appendSsrModuleRegistration(rewritten.code, realPath, state.root, isSsr));
2999
- return {
3000
- code: rewritten.code,
3001
- map: rewritten.map
3002
- };
3040
+ rewritten.edit(registerSfcModule(state, rewritten.code, realPath, isSsr));
3041
+ return loadedSfcModule(rewritten.code, rewritten.map, state.isProduction, isSsr, compiled);
3003
3042
  }
3004
3043
  function loadDefinePageArtifact(state, realPath, ssr) {
3005
3044
  return {
@@ -3031,7 +3070,7 @@ function loadHook(state, id, loadOptions) {
3031
3070
  const realPath = sourceRequest.vizeVirtualPath ?? sourceRequest.normalizedFsId ?? sourceRequest.normalizedVuePath ?? styleRequest.path;
3032
3071
  const lang = styleRequest.styleLang ?? null;
3033
3072
  const scoped = styleRequest.styleScoped ?? null;
3034
- const fallbackCompiled = loadOptions?.ssr ? state.ssrCache.get(realPath) ?? state.cache.get(realPath) : state.cache.get(realPath) ?? state.ssrCache.get(realPath);
3073
+ const fallbackCompiled = getCompiledStyleSource(state, realPath, !!loadOptions?.ssr);
3035
3074
  const blockIndex = styleRequest.styleIndex ?? -1;
3036
3075
  if (fallbackCompiled?.styles && blockIndex >= 0 && blockIndex < fallbackCompiled.styles.length) {
3037
3076
  const block = fallbackCompiled.styles[blockIndex];
@@ -3134,7 +3173,7 @@ function transformJsxRequest(state, code, id, options) {
3134
3173
  };
3135
3174
  }
3136
3175
  async function transformHook(state, code, id, options) {
3137
- if (!id.startsWith("\0") && !id.includes(".vue.ts") && !isJsxComponentPath(id)) return null;
3176
+ if (!id.startsWith("\0") && !id.includes(".vue") && !isJsxComponentPath(id)) return null;
3138
3177
  const pluginVisibleVirtualPath = fromPluginVisibleVirtualId(id);
3139
3178
  const jsxResult = transformJsxRequest(state, code, id, { ssr: options?.ssr });
3140
3179
  if (jsxResult !== void 0) return jsxResult;
@@ -3160,7 +3199,10 @@ function getVueModuleFileCandidates(vueFile) {
3160
3199
  toVirtualId(vueFile, true),
3161
3200
  toPluginVisibleVirtualId(vueFile, true),
3162
3201
  toPluginVisibleVirtualId(vueFile).split("?")[0],
3163
- vueFile
3202
+ vueFile,
3203
+ `${vueFile}.ts`,
3204
+ `${vueFile}.ts?vue&vize`,
3205
+ `${vueFile}.ts?vue&vize-ssr`
3164
3206
  ];
3165
3207
  const viteFsCandidates = candidates.flatMap((candidate) => {
3166
3208
  const viteFsId = toViteFsFileId(candidate);
@@ -4004,6 +4046,10 @@ function resolveCompatibilityOptions(options, compilerConfig = {}) {
4004
4046
  function aliasSortKey(find) {
4005
4047
  return typeof find === "string" ? find.length : find.source.length;
4006
4048
  }
4049
+ /** Vite 8 supplies SSR identity through the environment instead of hook arguments. */
4050
+ function resolveHookSsr(context, options) {
4051
+ return options?.ssr ?? (context.environment?.name === "ssr" || context.environment?.name === "server");
4052
+ }
4007
4053
  //#endregion
4008
4054
  //#region src/plugin/index.ts
4009
4055
  function vize(options = {}) {
@@ -4148,16 +4194,23 @@ function vize(options = {}) {
4148
4194
  state.logger.log("Cache keys:", [...state.cache.keys()].slice(0, 3));
4149
4195
  },
4150
4196
  resolveId(id, importer, options) {
4151
- return resolveIdHook(this, state, id, importer, options);
4197
+ return resolveIdHook(this, state, id, importer, {
4198
+ ...options,
4199
+ ssr: resolveHookSsr(this, options)
4200
+ });
4152
4201
  },
4153
4202
  load(id, loadOptions) {
4154
4203
  return loadHook(state, id, {
4155
4204
  ...loadOptions,
4205
+ ssr: resolveHookSsr(this, loadOptions),
4156
4206
  addWatchFile: this.addWatchFile.bind(this)
4157
4207
  });
4158
4208
  },
4159
4209
  async transform(code, id, transformOptions) {
4160
- return transformHook(state, code, id, transformOptions);
4210
+ return transformHook(state, code, id, {
4211
+ ...transformOptions,
4212
+ ssr: resolveHookSsr(this, transformOptions)
4213
+ });
4161
4214
  },
4162
4215
  async hotUpdate(options) {
4163
4216
  return handleHotUpdateEnvironmentHook(state, this.environment, options);
@@ -0,0 +1,2 @@
1
+ import { t as vize } from "./plugin-Bu9B_IUr.mjs";
2
+ export { vize };
@@ -1,8 +1,8 @@
1
1
  import { i as resolveConfigExport, r as loadConfig } from "./config-PP6EAmWc.mjs";
2
2
  import { createRequire } from "node:module";
3
- import { randomUUID } from "node:crypto";
3
+ import { createHash, randomUUID } from "node:crypto";
4
4
  import path from "node:path";
5
- import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
5
+ import { mkdirSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
6
6
  import { glob } from "tinyglobby";
7
7
  import { spawn, spawnSync } from "node:child_process";
8
8
  import os from "node:os";
@@ -27,11 +27,43 @@ function resolveVitePlus() {
27
27
  };
28
28
  }
29
29
  const catalogs = /* @__PURE__ */ new Map();
30
+ function catalogCacheFile(binary) {
31
+ try {
32
+ const stat = statSync(binary);
33
+ const key = createHash("sha256").update(binary).update("\0").update(String(stat.mtimeMs)).update("\0").update(String(stat.size)).digest("hex");
34
+ return path.join(os.tmpdir(), "vize-oxlint-rules", `${key}.json`);
35
+ } catch {
36
+ return;
37
+ }
38
+ }
39
+ function readCatalogCache(file) {
40
+ if (!file) return void 0;
41
+ try {
42
+ const parsed = JSON.parse(readFileSync(file, "utf8"));
43
+ if (!Array.isArray(parsed) || parsed.some((rule) => typeof rule !== "string")) return void 0;
44
+ return new Set(parsed);
45
+ } catch {
46
+ return;
47
+ }
48
+ }
49
+ function writeCatalogCache(file, rules) {
50
+ if (!file) return;
51
+ try {
52
+ mkdirSync(path.dirname(file), { recursive: true });
53
+ writeFileSync(file, JSON.stringify([...rules].sort()), { mode: 384 });
54
+ } catch {}
55
+ }
30
56
  /** Only disable rules supported by the consumer's bundled Oxlint. */
31
57
  function availableVueRules() {
32
58
  const { binary } = resolveVitePlus();
33
59
  const cached = catalogs.get(binary);
34
60
  if (cached) return cached;
61
+ const cacheFile = catalogCacheFile(binary);
62
+ const stored = readCatalogCache(cacheFile);
63
+ if (stored) {
64
+ catalogs.set(binary, stored);
65
+ return stored;
66
+ }
35
67
  const directory = mkdtempSync(path.join(os.tmpdir(), "vize-oxlint-rules-"));
36
68
  try {
37
69
  writeFileSync(path.join(directory, "package.json"), "{\"name\":\"vize-rule-catalog\",\"private\":true}");
@@ -43,14 +75,20 @@ function availableVueRules() {
43
75
  ], {
44
76
  cwd: directory,
45
77
  encoding: "utf8",
46
- timeout: 1e4,
78
+ timeout: 6e4,
47
79
  maxBuffer: 4 * 1024 * 1024
48
80
  });
81
+ if (result.error && "code" in result.error && result.error.code === "ETIMEDOUT") {
82
+ const available = /* @__PURE__ */ new Set();
83
+ catalogs.set(binary, available);
84
+ return available;
85
+ }
49
86
  if (result.error || result.status !== 0) throw new Error(`Cannot read installed Vite+ lint rules: ${result.error?.message ?? result.stderr}`);
50
87
  const rules = JSON.parse(result.stdout);
51
88
  if (!Array.isArray(rules)) throw new Error("Installed Vite+ returned an invalid lint rule catalog");
52
89
  const available = new Set(rules.filter((rule) => rule.scope === "vue").map((rule) => rule.value));
53
90
  catalogs.set(binary, available);
91
+ writeCatalogCache(cacheFile, available);
54
92
  return available;
55
93
  } finally {
56
94
  rmSync(directory, {
@@ -106,10 +144,11 @@ async function runTools(task, args, metadata, vp, native, execute) {
106
144
  })).filter((file) => file.endsWith(".vue"));
107
145
  if (vue.length) await vize("fmt", [formatCheck ? "--check" : "--write", ...vue]);
108
146
  }
109
- await run(vp, [
147
+ const oxfmtPatterns = patterns.filter((pattern) => !pattern.endsWith(".vue"));
148
+ if (oxfmtPatterns.length || patterns.length === 0) await run(vp, [
110
149
  "fmt",
111
150
  formatCheck ? "--check" : "--write",
112
- ...patterns
151
+ ...oxfmtPatterns
113
152
  ]);
114
153
  }
115
154
  return status;
@@ -118,7 +157,7 @@ async function runTask(argv) {
118
157
  const [task, ...rest] = argv;
119
158
  const args = rest[0] === "--" ? rest.slice(1) : rest;
120
159
  if (task === "editor:setup") {
121
- const { setupEditor } = await import("./editor-D3tfVb0Z.mjs");
160
+ const { setupEditor } = await import("./editor-Dtf01qrY.mjs");
122
161
  await setupEditor();
123
162
  return 0;
124
163
  }
@@ -182,7 +221,7 @@ async function runNative(command, argv, metadata, native = nativeBinary(), spawn
182
221
  command
183
222
  };
184
223
  const config = metadata.config === void 0 ? await loadConfig(process.cwd(), { env }) ?? {} : await resolveConfigExport(metadata.config, env);
185
- const file = path.resolve(`.vize-vp-${randomUUID()}.json`);
224
+ const file = path.join(os.tmpdir(), `.vize-vp-${randomUUID()}.json`);
186
225
  try {
187
226
  await writeFile(file, JSON.stringify(config), {
188
227
  flag: "wx",
@@ -333,6 +333,10 @@ interface TypeCheckerConfig {
333
333
  * Reserved Corsa server count. The direct project-session runner currently supports only 1.
334
334
  */
335
335
  servers?: number;
336
+ /**
337
+ * Hard bound in milliseconds for each editor Corsa request. Defaults to 60000; use a larger value for large cold projects.
338
+ */
339
+ lspRequestTimeoutMs?: number;
336
340
  }
337
341
  /**
338
342
  * Formatter options
@@ -1158,11 +1162,10 @@ interface VizeOptions extends ExperimentalPluginOptions {
1158
1162
  templateSyntax?: "standard" | "strict" | "quirks";
1159
1163
  /** Vue whitespace strategy, or Vize's narrow Vue 2 line-break migration mode. @default "condense" */
1160
1164
  whitespace?: "condense" | "preserve" | "vue2-line-breaks";
1161
- /**
1162
- * Root directory to scan for .vue files
1163
- * @default Vite's root
1164
- */
1165
+ /** Root directory to scan for .vue files; defaults to Vite's root. */
1165
1166
  root?: string;
1167
+ /** Framework manifest root; registers relative IDs, including external SFCs. */
1168
+ ssrModuleIdRoot?: string;
1166
1169
  /**
1167
1170
  * Glob patterns to scan for .vue files during pre-compilation
1168
1171
  * Use an empty array to disable startup pre-compilation and compile on demand.
@@ -1,4 +1,4 @@
1
- import { _ as LinterConfig, g as FormatterConfig, h as CompilerConfig, m as UserConfigExport, p as UserConfig$1, t as VizeOptions, v as TypeCheckerConfig } from "./types-BSmJ5UMW.mjs";
1
+ import { _ as LinterConfig, g as FormatterConfig, h as CompilerConfig, m as UserConfigExport, p as UserConfig$1, t as VizeOptions, v as TypeCheckerConfig } from "./types-VGJL5xEW.mjs";
2
2
  import { ConfigEnv, UserConfig, defineConfig as defineConfig$1 } from "vite-plus";
3
3
 
4
4
  //#region src/vite-plus/types.d.ts
@@ -1,10 +1,11 @@
1
1
  import { i as resolveConfigExport, r as loadConfig } from "./config-PP6EAmWc.mjs";
2
2
  import { t as mergeSharedConfig } from "./shared-config-dMxrrTkb.mjs";
3
- import { a as sourceConfigKey, i as resolveVitePlus, o as taskConfigKey, r as availableVueRules, t as runNative } from "./runner-8x__0QxE.mjs";
3
+ import { a as sourceConfigKey, i as resolveVitePlus, o as taskConfigKey, r as availableVueRules, t as runNative } from "./runner-Tb17R9ol.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import path from "node:path";
6
6
  import { readFileSync } from "node:fs";
7
7
  import { fileURLToPath } from "node:url";
8
+ import os from "node:os";
8
9
  import { readFile, rm, stat, writeFile } from "node:fs/promises";
9
10
  import { parse } from "jsonc-parser";
10
11
  //#region src/vite-plus/conflicts.ts
@@ -230,7 +231,7 @@ async function emitDeclarations(options, metadata) {
230
231
  const errors = [];
231
232
  const source = parse(await readFile(file, "utf8"), errors, { allowTrailingComma: true });
232
233
  if (errors.length || !source || typeof source !== "object") throw new Error(`Invalid TypeScript config: ${file}`);
233
- const temporary = path.join(path.dirname(file), `.vize-vp-${randomUUID()}.json`);
234
+ const temporary = path.join(os.tmpdir(), `.vize-vp-${randomUUID()}.json`);
234
235
  copies.set(file, temporary);
235
236
  const references = source.references ? await Promise.all(source.references.map(async (reference) => ({
236
237
  ...reference,
@@ -321,8 +322,8 @@ function defineConfig(config = {}, integration = {}) {
321
322
  const { options } = metadata;
322
323
  const plugins = compiler === false ? [...vp.plugins ?? []] : await withoutVueCompiler(vp.plugins ?? []);
323
324
  if (compiler !== false) {
324
- const { vize } = await import("./plugin-M-BPcy7h.mjs");
325
- plugins.unshift(vize({
325
+ const { vize } = await import("./plugin-DZDCjcNO.mjs");
326
+ plugins.push(vize({
326
327
  ...compiler,
327
328
  configMode: false,
328
329
  config: metadata.config
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/vite-plugin",
3
- "version": "0.429.0",
3
+ "version": "0.429.2",
4
4
  "description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
5
5
  "keywords": [
6
6
  "compiler",
@@ -51,18 +51,19 @@
51
51
  "access": "public"
52
52
  },
53
53
  "dependencies": {
54
- "@vizejs/native": "0.429.0",
55
- "@vizejs/unplugin": "0.429.0",
54
+ "@vizejs/native": "0.429.2",
55
+ "@vizejs/unplugin": "0.429.2",
56
56
  "jsonc-parser": "^3.3.1",
57
57
  "oxc-parser": "0.144.0",
58
58
  "tinyglobby": "0.2.17",
59
- "vize": "0.429.0"
59
+ "vize": "0.429.2"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@types/node": "25.9.2",
63
63
  "typescript": "6.0.3",
64
64
  "vite": "npm:@voidzero-dev/vite-plus-core@0.1.24",
65
- "vite-plus": "^0.2.3"
65
+ "vite-plus": "^0.2.3",
66
+ "vue": "3.5.35"
66
67
  },
67
68
  "peerDependencies": {
68
69
  "vite": "^7.3.0 || ^8.0.0",
@@ -88,7 +89,8 @@
88
89
  "check": "vp check src vite.config.ts",
89
90
  "check:fix": "vp check --fix src vite.config.ts",
90
91
  "fmt": "vp fmt --write src vite.config.ts",
91
- "test": "pnpm --dir ../../native build:debug && node src/test.ts && node --test src/vite-plus/*.test.ts",
92
+ "test": "node scripts/run-tests.mjs",
93
+ "test:prepared": "node scripts/run-tests.mjs --require-prepared && node src/test.ts && node --test src/vite-plus/*.test.ts",
92
94
  "test:types:real-vite": "vp exec node type-tests/plugin-vue/check.mjs"
93
95
  }
94
96
  }
@@ -1,2 +0,0 @@
1
- import { t as vize } from "./plugin-46Af12dC.mjs";
2
- export { vize };