@vizejs/vite-plugin 0.345.0 → 0.347.7

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.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as VizeVueVersion, c as VizeInspectorLintPlanRequest, d as LoadConfigOptions, f as ResolvedVizeConfig, i as VizeOptions, l as VizeInspectorOptions, m as VizeConfig, n as MacroArtifact, o as VizeVueFeatures, p as UserConfigExport, r as VizeCompatibilityOptions, s as VizeInspectorLintPlanProvider, t as CompiledModule, u as ConfigEnv } from "./types-T_Fu8G5I.mjs";
1
+ import { a as VizeVueVersion, c as VizeInspectorLintPlanRequest, d as LoadConfigOptions, f as ResolvedVizeConfig, i as VizeOptions, l as VizeInspectorOptions, m as VizeConfig, n as MacroArtifact, o as VizeVueFeatures, p as UserConfigExport, r as VizeCompatibilityOptions, s as VizeInspectorLintPlanProvider, t as CompiledModule, u as ConfigEnv } from "./types-D_BZmgv-.mjs";
2
2
  import { Plugin } from "vite";
3
3
 
4
4
  //#region src/virtual.d.ts
package/dist/index.mjs CHANGED
@@ -826,6 +826,7 @@ function clearBuildCaches(state) {
826
826
  */
827
827
  var CompiledModuleCache = class extends Map {
828
828
  #ownersByDependency = /* @__PURE__ */ new Map();
829
+ #dependenciesByOwner = /* @__PURE__ */ new Map();
829
830
  /**
830
831
  * Deliberately takes no entries: `Map`'s constructor would call the
831
832
  * overridden `set` from inside `super()`, before `#ownersByDependency` exists.
@@ -836,12 +837,15 @@ var CompiledModuleCache = class extends Map {
836
837
  set(file, compiled) {
837
838
  this.#unindex(file);
838
839
  super.set(file, compiled);
840
+ const dependencies = /* @__PURE__ */ new Set();
839
841
  for (const dependency of compiled.dependencies ?? []) {
840
842
  const key = path.resolve(dependency);
843
+ dependencies.add(key);
841
844
  const owners = this.#ownersByDependency.get(key);
842
845
  if (owners) owners.add(file);
843
846
  else this.#ownersByDependency.set(key, new Set([file]));
844
847
  }
848
+ this.#dependenciesByOwner.set(file, dependencies);
845
849
  return this;
846
850
  }
847
851
  delete(file) {
@@ -850,24 +854,40 @@ var CompiledModuleCache = class extends Map {
850
854
  }
851
855
  clear() {
852
856
  this.#ownersByDependency.clear();
857
+ this.#dependenciesByOwner.clear();
853
858
  super.clear();
854
859
  }
860
+ /**
861
+ * Evict a compiled value while retaining the dependency ownership that is
862
+ * required to route another hot update before Vite reloads the owner module.
863
+ * The next `set` reconciles that retained snapshot with the new compilation.
864
+ */
865
+ evict(file) {
866
+ return super.delete(file);
867
+ }
855
868
  /** The cached SFCs that `src`-import `resolvedDependency`. */
856
869
  ownersOf(resolvedDependency) {
857
870
  const owners = this.#ownersByDependency.get(resolvedDependency);
858
871
  return owners ? [...owners] : [];
859
872
  }
860
873
  #unindex(file) {
861
- for (const dependency of super.get(file)?.dependencies ?? []) {
862
- const key = path.resolve(dependency);
863
- const owners = this.#ownersByDependency.get(key);
874
+ for (const dependency of this.#dependenciesByOwner.get(file) ?? []) {
875
+ const owners = this.#ownersByDependency.get(dependency);
864
876
  if (!owners) continue;
865
877
  owners.delete(file);
866
- if (owners.size === 0) this.#ownersByDependency.delete(key);
878
+ if (owners.size === 0) this.#ownersByDependency.delete(dependency);
867
879
  }
880
+ this.#dependenciesByOwner.delete(file);
868
881
  }
869
882
  };
870
883
  /**
884
+ * Invalidate a compiled module without dropping its HMR dependency routing.
885
+ * Hand-built plain Maps retain their historical delete behaviour.
886
+ */
887
+ function evictCompiledModule(cache, file) {
888
+ return cache instanceof CompiledModuleCache ? cache.evict(file) : cache.delete(file);
889
+ }
890
+ /**
871
891
  * Owners of `resolvedDependency` in one cache.
872
892
  *
873
893
  * Plain `Map`s — the hand-built states in unit tests — keep the original linear
@@ -2843,25 +2863,7 @@ async function transformHook(state, code, id, options) {
2843
2863
  return null;
2844
2864
  }
2845
2865
  //#endregion
2846
- //#region src/plugin/hmr.ts
2847
- const VIZE_COMPONENTS_CSS_BASENAME = "vize-components.css";
2848
- const VIZE_COMPONENTS_CSS_FILE = `assets/${VIZE_COMPONENTS_CSS_BASENAME}`;
2849
- /**
2850
- * The cached SFCs that pulled `dependencyFile` in through
2851
- * `<script src>` / `<template src>` / `<style src>`.
2852
- *
2853
- * This runs as the first statement of every hot update, before the `.vue` fast
2854
- * path, so editing an ordinary SFC pays for it too. It used to walk both caches
2855
- * end to end with a `path.resolve` per dependency, which made HMR latency grow
2856
- * with the number of components in the project; the caches now carry a reverse
2857
- * index that answers it in constant time. See `compiled-module-cache.ts`.
2858
- */
2859
- function getVueFilesDependingOn(state, dependencyFile) {
2860
- const normalizedDependency = path.resolve(dependencyFile);
2861
- const owners = /* @__PURE__ */ new Set();
2862
- for (const cache of [state.cache, state.ssrCache]) for (const vueFile of ownersOfDependency(cache, normalizedDependency)) owners.add(vueFile);
2863
- return [...owners];
2864
- }
2866
+ //#region src/plugin/hmr-module-graph.ts
2865
2867
  function unique(values) {
2866
2868
  return [...new Set(values)];
2867
2869
  }
@@ -2890,16 +2892,15 @@ function getStyleModuleFileCandidates(styleId) {
2890
2892
  }
2891
2893
  async function collectModulesByFile(server, fileIds) {
2892
2894
  const modules = /* @__PURE__ */ new Set();
2893
- const graph = server.moduleGraph;
2894
2895
  for (const fileId of fileIds) {
2895
2896
  const add = (module) => {
2896
2897
  if (module) modules.add(module);
2897
2898
  };
2898
- add(graph.getModuleById?.(fileId));
2899
+ add(server.moduleGraph.getModuleById?.(fileId));
2899
2900
  if (!fileId.startsWith("\0")) try {
2900
- add(await graph.getModuleByUrl?.(fileId));
2901
+ add(await server.moduleGraph.getModuleByUrl?.(fileId));
2901
2902
  } catch {}
2902
- for (const module of graph.getModulesByFile(fileId) ?? []) add(module);
2903
+ for (const module of server.moduleGraph.getModulesByFile(fileId) ?? []) add(module);
2903
2904
  }
2904
2905
  return modules;
2905
2906
  }
@@ -2914,17 +2915,48 @@ function preferAcceptingClientModules(modules, requireAcceptingClientModule = fa
2914
2915
  function invalidateModules(server, modules) {
2915
2916
  for (const module of modules) server.moduleGraph.invalidateModule(module);
2916
2917
  }
2918
+ //#endregion
2919
+ //#region src/plugin/hmr.ts
2920
+ const VIZE_COMPONENTS_CSS_BASENAME = "vize-components.css";
2921
+ const VIZE_COMPONENTS_CSS_FILE = `assets/${VIZE_COMPONENTS_CSS_BASENAME}`;
2922
+ /**
2923
+ * The cached SFCs that pulled `dependencyFile` in through
2924
+ * `<script src>` / `<template src>` / `<style src>`.
2925
+ *
2926
+ * This runs as the first statement of every hot update, before the `.vue` fast
2927
+ * path, so editing an ordinary SFC pays for it too. It used to walk both caches
2928
+ * end to end with a `path.resolve` per dependency, which made HMR latency grow
2929
+ * with the number of components in the project; the caches now carry a reverse
2930
+ * index that answers it in constant time. See `compiled-module-cache.ts`.
2931
+ */
2932
+ function getVueFilesDependingOn(state, dependencyFile) {
2933
+ const normalizedDependency = path.resolve(dependencyFile);
2934
+ const owners = /* @__PURE__ */ new Set();
2935
+ for (const cache of [state.cache, state.ssrCache]) for (const vueFile of ownersOfDependency(cache, normalizedDependency)) owners.add(vueFile);
2936
+ return [...owners];
2937
+ }
2917
2938
  async function handleHotUpdateHook(state, ctx, options = {}) {
2918
2939
  const { file, server, read } = ctx;
2940
+ const clientDependencyOwners = new Set(ownersOfDependency(state.cache, path.resolve(file)));
2919
2941
  const dependencyOwners = getVueFilesDependingOn(state, file);
2920
2942
  if (dependencyOwners.length > 0) {
2921
2943
  const affectedModules = /* @__PURE__ */ new Set();
2922
2944
  for (const vueFile of dependencyOwners) {
2923
2945
  const collectedModules = await collectModulesByFile(server, getVueModuleFileCandidates(vueFile));
2924
2946
  const modules = options.requireAcceptingClientModule ? preferAcceptingClientModules(collectedModules, true) : collectedModules;
2925
- if (options.requireAcceptingClientModule && modules.size === 0) continue;
2926
- state.cache.delete(vueFile);
2927
- state.ssrCache.delete(vueFile);
2947
+ if (options.requireAcceptingClientModule && modules.size === 0) {
2948
+ if (!options.ensureAcceptingClientModule || !clientDependencyOwners.has(vueFile)) continue;
2949
+ try {
2950
+ const ensured = await options.ensureAcceptingClientModule(vueFile);
2951
+ modules.add(ensured);
2952
+ } catch (error) {
2953
+ state.logger.error(`Failed to restore the client HMR owner for ${vueFile}:`, error);
2954
+ options.onRecompileError?.(error);
2955
+ return;
2956
+ }
2957
+ }
2958
+ evictCompiledModule(state.cache, vueFile);
2959
+ evictCompiledModule(state.ssrCache, vueFile);
2928
2960
  state.collectedCss.delete(vueFile);
2929
2961
  state.precompileMetadata.delete(vueFile);
2930
2962
  state.pendingHmrUpdateTypes.set(vueFile, "full-reload");
@@ -3044,6 +3076,7 @@ async function handleHotUpdateEnvironmentHook(state, environment, options) {
3044
3076
  ...options,
3045
3077
  server
3046
3078
  }, {
3079
+ ensureAcceptingClientModule: (vueFile) => environment.moduleGraph.ensureEntryFromUrl(toPluginVisibleVirtualId(vueFile), false),
3047
3080
  requireAcceptingClientModule: true,
3048
3081
  onRecompileError: () => {
3049
3082
  recompileFailed = true;
@@ -1,4 +1,4 @@
1
- import { f as ResolvedVizeConfig } from "../types-T_Fu8G5I.mjs";
1
+ import { f as ResolvedVizeConfig } from "../types-D_BZmgv-.mjs";
2
2
  import { ResolvedConfig } from "vite";
3
3
 
4
4
  //#region src/internal/config-bridge.d.ts
@@ -409,6 +409,10 @@ interface LanguageServerConfig {
409
409
  * Enable completions
410
410
  */
411
411
  completion?: boolean;
412
+ /**
413
+ * Enable TypeScript signature help
414
+ */
415
+ signatureHelp?: boolean;
412
416
  /**
413
417
  * Enable hover information
414
418
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/vite-plugin",
3
- "version": "0.345.0",
3
+ "version": "0.347.7",
4
4
  "description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
5
5
  "keywords": [
6
6
  "compiler",
@@ -45,10 +45,10 @@
45
45
  "access": "public"
46
46
  },
47
47
  "dependencies": {
48
- "@vizejs/native": "0.345.0",
48
+ "@vizejs/native": "0.347.7",
49
49
  "oxc-parser": "0.133.0",
50
50
  "tinyglobby": "0.2.16",
51
- "vize": "0.345.0"
51
+ "vize": "0.347.7"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/node": "25.9.2",