@vizejs/vite-plugin 0.665.0 → 0.666.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as VizeInspectorLintPlanProvider, b as VizeConfig, c as VizeCompatibilityOptions, d as LoadConfigOptions, f as ResolvedVizeConfig, h as VueOptionsEntry, i as VizeVueFeatures, l as VizeVueVersion, m as VueOptions, n as CompiledModule, o as VizeInspectorLintPlanRequest, p as UserConfigExport, r as MacroArtifact, s as VizeInspectorOptions, t as VizeOptions, u as ConfigEnv } from "./types-CP73ozVq.mjs";
1
+ import { a as VizeInspectorLintPlanProvider, b as VizeConfig, c as VizeCompatibilityOptions, d as LoadConfigOptions, f as ResolvedVizeConfig, h as VueOptionsEntry, i as VizeVueFeatures, l as VizeVueVersion, m as VueOptions, n as CompiledModule, o as VizeInspectorLintPlanRequest, p as UserConfigExport, r as MacroArtifact, s as VizeInspectorOptions, t as VizeOptions, u as ConfigEnv } from "./types-mem20MPI.mjs";
2
2
  import { Plugin } from "vite";
3
3
 
4
4
  //#region src/plugin/compiler-config.d.ts
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as vize } from "./plugin-CAu9ew7B.mjs";
1
+ import { t as vize } from "./plugin-pJzKyVGe.mjs";
2
2
  import { u as rewriteStaticAssetUrls } from "./vue-version-BFh0eI6J.mjs";
3
3
  import { a as resolveViteConfigExport, i as resolveConfigExport, n as defineConfig, o as vizeConfigStore, r as loadConfig, t as VIZE_CONFIG_FILE_ENV } from "./config-LlMZcDZI.mjs";
4
4
  //#region src/index.ts
@@ -1,4 +1,4 @@
1
- import { f as ResolvedVizeConfig } from "../types-CP73ozVq.mjs";
1
+ import { f as ResolvedVizeConfig } from "../types-mem20MPI.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-pJzKyVGe.mjs";
2
+ export { vize };
@@ -212,32 +212,13 @@ function rewriteDefaultExportToSfcMain(code, moduleInfo = {
212
212
  return `${code.slice(0, exportStart)}const ${SFC_MAIN_NAME} =${code.slice(keywordEnd)}`;
213
213
  }
214
214
  /**
215
- * Locate `export default _sfc_main` when the caller has no analysis to hand.
216
- *
217
- * The string test is a sound pre-filter: the AST check below only succeeds when
218
- * the default export's declaration *is* the `_sfc_main` identifier, which cannot
219
- * happen unless that name occurs in the module.
215
+ * Insert `insertion` before `export default _sfc_main`. `moduleInfo` must
216
+ * describe `code` exactly (offsets are used verbatim), so the module is never
217
+ * parsed again (#3425).
220
218
  */
221
- function findSfcMainDefaultExport(code) {
222
- if (!code.includes(SFC_MAIN_NAME)) return {
223
- defaultExportStart: null,
224
- defaultExportEnd: null,
225
- defaultExportIsSfcMain: false
226
- };
227
- const defaultExport = findDefaultExport(parseProgram(code));
228
- return {
229
- defaultExportStart: getNodeStart(defaultExport),
230
- defaultExportEnd: getNodeEnd(defaultExport),
231
- defaultExportIsSfcMain: isSfcMainDefaultExport(defaultExport)
232
- };
233
- }
234
- function insertBeforeSfcMainDefaultExport(code, insertion, options = {}) {
235
- const { defaultExportStart: exportStart, defaultExportEnd: exportEnd, defaultExportIsSfcMain } = options.moduleInfo ?? findSfcMainDefaultExport(code);
236
- if (!defaultExportIsSfcMain || exportStart == null) return code;
237
- if (options.normalizeSemicolon && exportEnd != null) {
238
- const suffixStart = code[exportEnd] === ";" ? exportEnd + 1 : exportEnd;
239
- return `${code.slice(0, exportStart)}${insertion}\nexport default ${SFC_MAIN_NAME};${code.slice(suffixStart)}`;
240
- }
219
+ function insertBeforeSfcMainDefaultExport(code, insertion, moduleInfo) {
220
+ const exportStart = moduleInfo.defaultExportStart;
221
+ if (!moduleInfo.defaultExportIsSfcMain || exportStart == null) return code;
241
222
  return `${code.slice(0, exportStart)}${insertion}\n${code.slice(exportStart)}`;
242
223
  }
243
224
  //#endregion
@@ -386,22 +367,25 @@ function assembleComponentOutput(compiled) {
386
367
  const hasNamedRenderExport = moduleInfo.hasNamedRenderExport;
387
368
  const hasNamedSsrRenderExport = moduleInfo.hasNamedSsrRenderExport;
388
369
  const hasSfcMainDefined = moduleInfo.hasSfcMainDefined;
370
+ let exportsSfcMain = true;
389
371
  if (hasExportDefault && !hasSfcMainDefined) {
390
372
  emitted.edit(rewriteDefaultExportToSfcMain(emitted.code, moduleInfo));
391
373
  if (compiled.hasScoped && compiled.scopeId) emitted.edit(`${emitted.code}\n_sfc_main.__scopeId = "data-v-${compiled.scopeId}";`);
392
374
  emitted.edit(`${emitted.code}\nexport default _sfc_main;`);
393
375
  } else if (hasExportDefault && hasSfcMainDefined) {
394
- if (compiled.hasScoped && compiled.scopeId) emitted.edit(insertBeforeSfcMainDefaultExport(emitted.code, `_sfc_main.__scopeId = "data-v-${compiled.scopeId}";`, { moduleInfo }));
376
+ exportsSfcMain = moduleInfo.defaultExportIsSfcMain;
377
+ if (compiled.hasScoped && compiled.scopeId) emitted.edit(insertBeforeSfcMainDefaultExport(emitted.code, `_sfc_main.__scopeId = "data-v-${compiled.scopeId}";`, moduleInfo));
395
378
  } else if (!hasExportDefault && !hasSfcMainDefined && hasNamedRenderExport) {
396
379
  const scope = compiled.hasScoped && compiled.scopeId ? `, __scopeId: "data-v-${compiled.scopeId}"` : "";
397
380
  emitted.edit(`${emitted.code}\nconst _sfc_main = { render${scope} };\nexport default _sfc_main;`);
398
381
  } else if (!hasExportDefault && !hasSfcMainDefined && hasNamedSsrRenderExport) {
399
382
  const scope = compiled.hasScoped && compiled.scopeId ? `, __scopeId: "data-v-${compiled.scopeId}"` : "";
400
383
  emitted.edit(`${emitted.code}\nconst _sfc_main = { ssrRender${scope} };\nexport default _sfc_main;`);
401
- }
384
+ } else exportsSfcMain = false;
402
385
  return {
403
386
  emitted,
404
- hasExportDefault
387
+ hasExportDefault,
388
+ exportsSfcMain
405
389
  };
406
390
  }
407
391
  //#endregion
@@ -699,7 +683,7 @@ function generateOutput(compiled, options) {
699
683
  */
700
684
  function generateOutputWithMap(compiled, options) {
701
685
  const { customElement, isProduction, isDev, ssr, hmrUpdateType, extractCss, filePath, root } = options;
702
- const { emitted, hasExportDefault } = assembleComponentOutput(compiled);
686
+ const { emitted, hasExportDefault, exportsSfcMain } = assembleComponentOutput(compiled);
703
687
  if (usesStyleImports(compiled, options)) {
704
688
  const styleImports = [];
705
689
  const cssModuleImports = [];
@@ -731,8 +715,8 @@ function generateOutputWithMap(compiled, options) {
731
715
  }
732
716
  const allImports = [...styleImports, ...cssModuleImports].join("\n");
733
717
  if (allImports) emitted.edit(insertAfterStaticImports(emitted.code, allImports));
734
- if (customElementStyleBindings.length > 0) emitted.edit(insertBeforeSfcMainDefaultExport(emitted.code, `_sfc_main.styles = [${customElementStyleBindings.join(", ")}];`, { normalizeSemicolon: true }));
735
- else if (cssModuleImports.length > 0) {
718
+ if (exportsSfcMain && customElementStyleBindings.length > 0) emitted.edit(`${emitted.code}\n_sfc_main.styles = [${customElementStyleBindings.join(", ")}];`);
719
+ else if (exportsSfcMain && cssModuleImports.length > 0) {
736
720
  const moduleBindings = [];
737
721
  for (const block of compiled.styles) if (isCssModule(block)) {
738
722
  const bindingName = typeof block.module === "string" ? block.module : "$style";
@@ -742,7 +726,7 @@ function generateOutputWithMap(compiled, options) {
742
726
  });
743
727
  }
744
728
  const cssModuleSetup = moduleBindings.map((m) => `_sfc_main.__cssModules = _sfc_main.__cssModules || {};\n_sfc_main.__cssModules[${JSON.stringify(m.name)}] = ${m.bindingName};`).join("\n");
745
- emitted.edit(insertBeforeSfcMainDefaultExport(emitted.code, cssModuleSetup, { normalizeSemicolon: true }));
729
+ emitted.edit(`${emitted.code}\n${cssModuleSetup}`);
746
730
  }
747
731
  } else if (!ssr && compiled.css && !(isProduction && extractCss)) emitted.edit(prependInlineStyleInjection(emitted.code, compiled.css, compiled.scopeId));
748
732
  if (!isProduction && isDev && hasExportDefault) {
@@ -1144,13 +1144,7 @@ type ModuleOutputInfo = {
1144
1144
  hasNamedRenderExport: boolean;
1145
1145
  hasNamedSsrRenderExport: boolean;
1146
1146
  defaultExportKeywordEnd: number | null;
1147
- defaultExportStart: number | null;
1148
- /**
1149
- * End offset of the whole `export default ...` statement, or `null`.
1150
- *
1151
- * Recorded so {@link insertBeforeSfcMainDefaultExport} can reuse the caller's
1152
- * analysis instead of parsing the module a second time (#3425).
1153
- */
1147
+ defaultExportStart: number | null; /** End offset of the whole `export default ...` statement, or `null`. */
1154
1148
  defaultExportEnd: number | null;
1155
1149
  /**
1156
1150
  * Whether the default export's declaration is exactly the `_sfc_main`
@@ -1,4 +1,4 @@
1
- import { _ as FormatterConfig, g as CompilerConfig, h as VueOptionsEntry, m as VueOptions, p as UserConfigExport, t as VizeOptions, v as LinterConfig, y as TypeCheckerConfig } from "./types-CP73ozVq.mjs";
1
+ import { _ as FormatterConfig, g as CompilerConfig, h as VueOptionsEntry, m as VueOptions, p as UserConfigExport, t as VizeOptions, v as LinterConfig, y as TypeCheckerConfig } from "./types-mem20MPI.mjs";
2
2
  import { ConfigEnv, UserConfig, defineConfig as defineConfig$1 } from "vite-plus";
3
3
 
4
4
  //#region src/vite-plus/types.d.ts
@@ -400,7 +400,7 @@ function defineConfig(config = {}, integration = {}) {
400
400
  const legacy = compiler !== false && (await import("./vue-version-DOjZaMiI.mjs")).isLegacyVueCompatibilityMode(compiler);
401
401
  const plugins = compiler === false || legacy ? [...vp.plugins ?? []] : await withoutVueCompiler(vp.plugins ?? []);
402
402
  if (compiler !== false) {
403
- const { vize } = await import("./plugin-hkzt_w0x.mjs");
403
+ const { vize } = await import("./plugin-CwodSCpW.mjs");
404
404
  plugins.push(vize({
405
405
  ...plugin,
406
406
  configMode: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/vite-plugin",
3
- "version": "0.665.0",
3
+ "version": "0.666.0",
4
4
  "description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
5
5
  "keywords": [
6
6
  "compiler",
@@ -51,13 +51,13 @@
51
51
  "access": "public"
52
52
  },
53
53
  "dependencies": {
54
- "@vizejs/native": "0.665.0",
55
- "@vizejs/unplugin": "0.665.0",
54
+ "@vizejs/native": "0.666.0",
55
+ "@vizejs/unplugin": "0.666.0",
56
56
  "jsonc-parser": "^3.3.1",
57
57
  "oxc-parser": "0.144.0",
58
58
  "picomatch": "4.0.5",
59
59
  "tinyglobby": "0.2.17",
60
- "vize": "0.665.0"
60
+ "vize": "0.666.0"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/node": "25.9.2",
@@ -1,2 +0,0 @@
1
- import { t as vize } from "./plugin-CAu9ew7B.mjs";
2
- export { vize };