@vizejs/vite-plugin 0.429.0 → 0.429.1

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 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-CwtUr1uY.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-DfwtlJyA.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-CwtUr1uY.mjs";
2
2
  import { ResolvedConfig } from "vite";
3
3
 
4
4
  //#region src/internal/config-bridge.d.ts
@@ -0,0 +1,2 @@
1
+ import { t as vize } from "./plugin-DfwtlJyA.mjs";
2
+ export { vize };
@@ -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) {
@@ -710,26 +710,26 @@ function isVizeSsrVirtual(id) {
710
710
  function toVirtualId(realPath, ssr = false) {
711
711
  return createViteVirtualId(realPath, ssr);
712
712
  }
713
- function toPluginVisibleVirtualId(realPath, ssr = false, querySuffix = "") {
713
+ function toPluginVisibleVirtualId(realPath, _ssr = false, querySuffix = "") {
714
714
  const params = new URLSearchParams(querySuffix.startsWith("?") ? querySuffix.slice(1) : "");
715
715
  params.delete("vue");
716
716
  params.delete("vize");
717
717
  params.delete("vize-ssr");
718
718
  const rest = params.toString();
719
- return `${realPath}.ts?vue&${ssr ? "vize-ssr" : "vize"}${rest ? `&${rest}` : ""}`;
719
+ return `${realPath}?vue&vize${rest ? `&${rest}` : ""}`;
720
720
  }
721
721
  /**
722
722
  * String pre-gate for {@link fromPluginVisibleVirtualId}, so ordinary module IDs
723
723
  * never cross the native boundary (#3427).
724
724
  *
725
- * A non-null result requires `request.path` to end with `.vue.ts` or `.vue.tsx`
725
+ * A non-null result requires `request.path` to end with `.vue`, `.vue.ts` or `.vue.tsx`
726
726
  * and `request.querySuffix` to be non-empty. `request.path` is `id` up to the
727
727
  * first `?` and `querySuffix` is non-empty exactly when that `?` exists, so both
728
728
  * conditions imply these two substring tests. The tests are strictly weaker, so
729
729
  * everything the old code accepted still reaches the classifier.
730
730
  */
731
731
  function mayBePluginVisibleVirtualId(id) {
732
- return !id.startsWith("\0") && id.includes(".vue.ts") && id.includes("?");
732
+ return !id.startsWith("\0") && id.includes(".vue") && id.includes("?");
733
733
  }
734
734
  function fromPluginVisibleVirtualId(id) {
735
735
  if (!mayBePluginVisibleVirtualId(id)) return null;
@@ -753,7 +753,7 @@ function stripFsPrefix(path) {
753
753
  return path.startsWith("/@fs") ? path.slice(4) : path;
754
754
  }
755
755
  function isPluginVisibleVueVirtualPath(path) {
756
- return path.endsWith(".vue.ts") || path.endsWith(".vue.tsx");
756
+ return path.endsWith(".vue") || path.endsWith(".vue.ts") || path.endsWith(".vue.tsx");
757
757
  }
758
758
  function stripPluginVisibleVueVirtualSuffix(path) {
759
759
  if (path.endsWith(".vue.tsx")) return path.slice(0, -4);
@@ -2393,7 +2393,7 @@ function nativeCssAliasRules(state) {
2393
2393
  return state.cssAliasRules.length === 0 ? EMPTY_NATIVE_ALIAS_RULES : state.cssAliasRules.map(toNativeCssAliasRule);
2394
2394
  }
2395
2395
  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");
2396
+ 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
2397
  }
2398
2398
  function classifyImporterRequest(importer) {
2399
2399
  return importer ? classifyVitePluginRequest(importer) : null;
@@ -2780,8 +2780,8 @@ const SFC_MAIN_DECLARATION = /\b(?:const|let|var)\s+_sfc_main\s*=/;
2780
2780
  * The key must be the module's path relative to the Vite root with POSIX
2781
2781
  * separators, because that is what the client manifest is keyed on.
2782
2782
  */
2783
- function ssrModuleRegistrationCode(filePath, root, helpers = {}) {
2784
- const moduleId = JSON.stringify(toManifestModuleId(filePath, root));
2783
+ function ssrModuleRegistrationCode(filePath, root, helpers = {}, frameworkRoot) {
2784
+ const moduleId = JSON.stringify(frameworkRoot === void 0 ? toManifestModuleId(filePath, root) : path.relative(frameworkRoot, filePath).replace(/\\/g, "/"));
2785
2785
  const useSSRContext = helpers.useSSRContext ?? "__vize_useSSRContext";
2786
2786
  const sfcSetup = helpers.sfcSetup ?? "__vize_sfc_setup";
2787
2787
  return {
@@ -2825,13 +2825,13 @@ function toManifestModuleId(filePath, root) {
2825
2825
  * a boundary placeholder — have no component object to wrap and are returned
2826
2826
  * untouched.
2827
2827
  */
2828
- function appendSsrModuleRegistration(code, filePath, root, isSsr) {
2828
+ function appendSsrModuleRegistration(code, filePath, root, isSsr, frameworkRoot) {
2829
2829
  if (!isSsr || !SFC_MAIN_DECLARATION.test(code)) return code;
2830
2830
  if (code.includes(REGISTRATION_MARKER)) return code;
2831
2831
  const { prologue, epilogue } = ssrModuleRegistrationCode(filePath, root, {
2832
2832
  useSSRContext: freeIdentifier("__vize_useSSRContext", code),
2833
2833
  sfcSetup: freeIdentifier("__vize_sfc_setup", code)
2834
- });
2834
+ }, frameworkRoot);
2835
2835
  return `${prologue}\n${code}\n${epilogue}`;
2836
2836
  }
2837
2837
  /**
@@ -2847,6 +2847,10 @@ function freeIdentifier(base, code) {
2847
2847
  if (!new RegExp(`\\b${candidate}\\b`).test(code)) return candidate;
2848
2848
  }
2849
2849
  }
2850
+ /** Keep compiler/config root separate from Nuxt's source-relative manifest IDs. */
2851
+ function registerSfcModule(state, code, filePath, isSsr) {
2852
+ return appendSsrModuleRegistration(code, filePath, state.root, isSsr, state.mergedOptions.ssrModuleIdRoot);
2853
+ }
2850
2854
  //#endregion
2851
2855
  //#region src/plugin/vite-transform.ts
2852
2856
  function createVirtualTypeScriptTransformer(viteApi) {
@@ -2923,6 +2927,15 @@ async function transformVizeVirtualModule(state, code, realPath, ssr, forceTypeS
2923
2927
  }
2924
2928
  }
2925
2929
  //#endregion
2930
+ //#region src/plugin/load-style.ts
2931
+ /** Nuxt can load an emitted CSS entry before loading its owning SFC. */
2932
+ function getCompiledStyleSource(state, realPath, ssr) {
2933
+ const cache = getEnvironmentCache(state, ssr);
2934
+ const compiled = cache.get(realPath) ?? state.cache.get(realPath) ?? state.ssrCache.get(realPath);
2935
+ if (compiled || !shouldLoadCompiledVueSfcPath(state, realPath) || !fs.existsSync(realPath)) return compiled;
2936
+ return compileFile(realPath, cache, getCompileOptionsForRequest(state, ssr));
2937
+ }
2938
+ //#endregion
2926
2939
  //#region src/plugin/load.ts
2927
2940
  const SERVER_PLACEHOLDER_CODE = `import { createElementBlock, defineComponent } from "vue";
2928
2941
  export default defineComponent({
@@ -2995,7 +3008,7 @@ function loadCompiledSfcModule(state, realPath, isSsr, currentBase, loadOptions)
2995
3008
  rewritten.edit(rewriteDynamicTemplateImports(rewritten.code, state.dynamicImportAliasRules));
2996
3009
  rewritten.edit(rewriteStaticAssetUrls(rewritten.code, state.dynamicImportAliasRules));
2997
3010
  rewritten.edit(rewriteImportMetaGlobBase(rewritten.code, realPath, state.root));
2998
- rewritten.edit(appendSsrModuleRegistration(rewritten.code, realPath, state.root, isSsr));
3011
+ rewritten.edit(registerSfcModule(state, rewritten.code, realPath, isSsr));
2999
3012
  return {
3000
3013
  code: rewritten.code,
3001
3014
  map: rewritten.map
@@ -3031,7 +3044,7 @@ function loadHook(state, id, loadOptions) {
3031
3044
  const realPath = sourceRequest.vizeVirtualPath ?? sourceRequest.normalizedFsId ?? sourceRequest.normalizedVuePath ?? styleRequest.path;
3032
3045
  const lang = styleRequest.styleLang ?? null;
3033
3046
  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);
3047
+ const fallbackCompiled = getCompiledStyleSource(state, realPath, !!loadOptions?.ssr);
3035
3048
  const blockIndex = styleRequest.styleIndex ?? -1;
3036
3049
  if (fallbackCompiled?.styles && blockIndex >= 0 && blockIndex < fallbackCompiled.styles.length) {
3037
3050
  const block = fallbackCompiled.styles[blockIndex];
@@ -3134,7 +3147,7 @@ function transformJsxRequest(state, code, id, options) {
3134
3147
  };
3135
3148
  }
3136
3149
  async function transformHook(state, code, id, options) {
3137
- if (!id.startsWith("\0") && !id.includes(".vue.ts") && !isJsxComponentPath(id)) return null;
3150
+ if (!id.startsWith("\0") && !id.includes(".vue") && !isJsxComponentPath(id)) return null;
3138
3151
  const pluginVisibleVirtualPath = fromPluginVisibleVirtualId(id);
3139
3152
  const jsxResult = transformJsxRequest(state, code, id, { ssr: options?.ssr });
3140
3153
  if (jsxResult !== void 0) return jsxResult;
@@ -3160,7 +3173,10 @@ function getVueModuleFileCandidates(vueFile) {
3160
3173
  toVirtualId(vueFile, true),
3161
3174
  toPluginVisibleVirtualId(vueFile, true),
3162
3175
  toPluginVisibleVirtualId(vueFile).split("?")[0],
3163
- vueFile
3176
+ vueFile,
3177
+ `${vueFile}.ts`,
3178
+ `${vueFile}.ts?vue&vize`,
3179
+ `${vueFile}.ts?vue&vize-ssr`
3164
3180
  ];
3165
3181
  const viteFsCandidates = candidates.flatMap((candidate) => {
3166
3182
  const viteFsId = toViteFsFileId(candidate);
@@ -4004,6 +4020,10 @@ function resolveCompatibilityOptions(options, compilerConfig = {}) {
4004
4020
  function aliasSortKey(find) {
4005
4021
  return typeof find === "string" ? find.length : find.source.length;
4006
4022
  }
4023
+ /** Vite 8 supplies SSR identity through the environment instead of hook arguments. */
4024
+ function resolveHookSsr(context, options) {
4025
+ return options?.ssr ?? (context.environment?.name === "ssr" || context.environment?.name === "server");
4026
+ }
4007
4027
  //#endregion
4008
4028
  //#region src/plugin/index.ts
4009
4029
  function vize(options = {}) {
@@ -4148,16 +4168,23 @@ function vize(options = {}) {
4148
4168
  state.logger.log("Cache keys:", [...state.cache.keys()].slice(0, 3));
4149
4169
  },
4150
4170
  resolveId(id, importer, options) {
4151
- return resolveIdHook(this, state, id, importer, options);
4171
+ return resolveIdHook(this, state, id, importer, {
4172
+ ...options,
4173
+ ssr: resolveHookSsr(this, options)
4174
+ });
4152
4175
  },
4153
4176
  load(id, loadOptions) {
4154
4177
  return loadHook(state, id, {
4155
4178
  ...loadOptions,
4179
+ ssr: resolveHookSsr(this, loadOptions),
4156
4180
  addWatchFile: this.addWatchFile.bind(this)
4157
4181
  });
4158
4182
  },
4159
4183
  async transform(code, id, transformOptions) {
4160
- return transformHook(state, code, id, transformOptions);
4184
+ return transformHook(state, code, id, {
4185
+ ...transformOptions,
4186
+ ssr: resolveHookSsr(this, transformOptions)
4187
+ });
4161
4188
  },
4162
4189
  async hotUpdate(options) {
4163
4190
  return handleHotUpdateEnvironmentHook(state, this.environment, options);
@@ -1158,11 +1158,10 @@ interface VizeOptions extends ExperimentalPluginOptions {
1158
1158
  templateSyntax?: "standard" | "strict" | "quirks";
1159
1159
  /** Vue whitespace strategy, or Vize's narrow Vue 2 line-break migration mode. @default "condense" */
1160
1160
  whitespace?: "condense" | "preserve" | "vue2-line-breaks";
1161
- /**
1162
- * Root directory to scan for .vue files
1163
- * @default Vite's root
1164
- */
1161
+ /** Root directory to scan for .vue files; defaults to Vite's root. */
1165
1162
  root?: string;
1163
+ /** Framework manifest root; registers relative IDs, including external SFCs. */
1164
+ ssrModuleIdRoot?: string;
1166
1165
  /**
1167
1166
  * Glob patterns to scan for .vue files during pre-compilation
1168
1167
  * 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-CwtUr1uY.mjs";
2
2
  import { ConfigEnv, UserConfig, defineConfig as defineConfig$1 } from "vite-plus";
3
3
 
4
4
  //#region src/vite-plus/types.d.ts
@@ -321,7 +321,7 @@ function defineConfig(config = {}, integration = {}) {
321
321
  const { options } = metadata;
322
322
  const plugins = compiler === false ? [...vp.plugins ?? []] : await withoutVueCompiler(vp.plugins ?? []);
323
323
  if (compiler !== false) {
324
- const { vize } = await import("./plugin-M-BPcy7h.mjs");
324
+ const { vize } = await import("./plugin-Cxx-XPU9.mjs");
325
325
  plugins.unshift(vize({
326
326
  ...compiler,
327
327
  configMode: false,
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.1",
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.1",
55
+ "@vizejs/unplugin": "0.429.1",
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.1"
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",
@@ -1,2 +0,0 @@
1
- import { t as vize } from "./plugin-46Af12dC.mjs";
2
- export { vize };