@vizejs/vite-plugin 0.682.0 → 0.684.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-CuBwh3up.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-DRbVPh2U.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-DeTv2aMw.mjs";
1
+ import { t as vize } from "./plugin-cSFUkcfU.mjs";
2
2
  import { u as rewriteStaticAssetUrls } from "./vue-version-B0qUneRk.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-CuBwh3up.mjs";
1
+ import { f as ResolvedVizeConfig } from "../types-DRbVPh2U.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-cSFUkcfU.mjs";
2
+ export { vize };
@@ -15,7 +15,7 @@ import * as vite from "vite";
15
15
  //#region src/hmr.ts
16
16
  function hasHmrChanges(prev, next) {
17
17
  if (!prev) return true;
18
- return hasViteHmrChanges(toHmrHashes(prev), toHmrHashes(next)) || runtimeFingerprint(prev) !== runtimeFingerprint(next) || styleFingerprint(prev) !== styleFingerprint(next);
18
+ return hasViteHmrChanges(toHmrHashes(prev), toHmrHashes(next)) || runtimeFingerprint(prev) !== runtimeFingerprint(next) || styleFingerprint(prev) !== styleFingerprint(next) || hasCustomBlockChanges(prev, next);
19
19
  }
20
20
  /**
21
21
  * Detect the type of HMR update needed based on content hash changes.
@@ -27,6 +27,7 @@ function hasHmrChanges(prev, next) {
27
27
  function detectHmrUpdateType(prev, next) {
28
28
  if (!prev) return detectViteHmrUpdateType(void 0, toHmrHashes(next));
29
29
  if (prev.scriptHash !== next.scriptHash) return "full-reload";
30
+ if (hasCustomBlockChanges(prev, next)) return "full-reload";
30
31
  if (prev.templateHash !== next.templateHash) return "template-only";
31
32
  if (prev.styleHash !== next.styleHash) return "style-only";
32
33
  if (runtimeFingerprint(prev) !== runtimeFingerprint(next)) return "full-reload";
@@ -48,6 +49,10 @@ function hasStyleChanges(prev, next) {
48
49
  if (!prev) return true;
49
50
  return prev.styleHash !== next.styleHash || styleFingerprint(prev) !== styleFingerprint(next);
50
51
  }
52
+ /** Whether custom-block content changed, including the first time blocks appear. */
53
+ function hasCustomBlockChanges(prev, next) {
54
+ return customBlockFingerprint(prev) !== customBlockFingerprint(next);
55
+ }
51
56
  function toHmrHashes(module) {
52
57
  return module ? {
53
58
  scriptHash: module.scriptHash,
@@ -78,6 +83,15 @@ function runtimeFingerprint(module) {
78
83
  dependencies: [...module.dependencies ?? []].sort()
79
84
  });
80
85
  }
86
+ function customBlockFingerprint(module) {
87
+ return JSON.stringify((module?.customBlocks ?? []).map((block) => ({
88
+ type: block.type,
89
+ content: block.content,
90
+ src: block.src ?? null,
91
+ attrs: block.attrs,
92
+ index: block.index
93
+ })));
94
+ }
81
95
  function styleFingerprint(module) {
82
96
  return JSON.stringify({
83
97
  css: module.css,
@@ -447,6 +461,97 @@ function assembleComponentOutput(compiled) {
447
461
  };
448
462
  }
449
463
  //#endregion
464
+ //#region src/custom-blocks.ts
465
+ const RESERVED_BLOCK_TYPES = new Set([
466
+ "style",
467
+ "script",
468
+ "template"
469
+ ]);
470
+ /** Map native `blockType` blocks onto the shape Vite emits and reloads. */
471
+ function normalizeCustomBlocks(blocks) {
472
+ if (!blocks) return [];
473
+ return blocks.map((block) => {
474
+ const attrs = {};
475
+ for (const attr of block.attrs ?? []) {
476
+ const value = attr.value;
477
+ attrs[attr.name] = value == null || value === "" ? true : value;
478
+ }
479
+ return {
480
+ type: block.blockType,
481
+ content: block.content,
482
+ src: block.src || null,
483
+ attrs,
484
+ index: block.index
485
+ };
486
+ });
487
+ }
488
+ /**
489
+ * Query for one custom block, without the leading `?`.
490
+ *
491
+ * `vue` is a bare flag (`vue&type=`), which is what user plugins match.
492
+ * Vite may re-serialize that empty param as `vue=&type=`; load accepts both.
493
+ * `index` is the block's position in the custom-block list. A `src` block
494
+ * carries `src=true` rather than the path. Other attributes follow, except `src`.
495
+ */
496
+ function customBlockQuery(block, index) {
497
+ const parts = [
498
+ "vue",
499
+ `type=${block.type}`,
500
+ `index=${index}`
501
+ ];
502
+ if (block.src) parts.push("src=true");
503
+ for (const [key, value] of Object.entries(block.attrs)) {
504
+ if (key === "src") continue;
505
+ parts.push(value === true ? key : `${key}=${value}`);
506
+ }
507
+ return parts.join("&");
508
+ }
509
+ function customBlockRequest(filePath, block, index) {
510
+ return `${filePath}?${customBlockQuery(block, index)}`;
511
+ }
512
+ /** Import plus call, matching the rspack custom-block wiring. */
513
+ function customBlockModuleCode(filePath, blocks) {
514
+ return blocks.map((block, index) => {
515
+ return `import block${index} from ${JSON.stringify(customBlockRequest(filePath, block, index))};\nif (typeof block${index} === 'function') block${index}(_sfc_main);`;
516
+ }).join("\n");
517
+ }
518
+ /**
519
+ * Insert `insertion` immediately before `export default _sfc_main`, so the
520
+ * call runs after `_sfc_main` exists and before importers read the export.
521
+ * Appends when that export is not a statement in this module.
522
+ */
523
+ function insertBeforeSfcMainDefaultExport(code, insertion) {
524
+ const block = insertion.endsWith("\n") ? insertion : `${insertion}\n`;
525
+ const lineStart = sfcMainDefaultExportLineStart(code);
526
+ if (lineStart < 0) return `${code}${code.endsWith("\n") ? "" : "\n"}${block}`;
527
+ return `${code.slice(0, lineStart)}${block}${code.slice(lineStart)}`;
528
+ }
529
+ function sfcMainDefaultExportLineStart(code) {
530
+ const marker = "export default _sfc_main";
531
+ let at = code.lastIndexOf(marker);
532
+ while (at >= 0) {
533
+ const lineStart = code.lastIndexOf("\n", at - 1) + 1;
534
+ if (code.slice(lineStart, at).trim() === "") return lineStart;
535
+ at = code.lastIndexOf(marker, at - 1);
536
+ }
537
+ return -1;
538
+ }
539
+ /** A Vue custom-block query: `type` is present and is not a built-in block. */
540
+ function parseCustomBlockQuery(id) {
541
+ const start = id.indexOf("?");
542
+ if (start < 0) return null;
543
+ const params = new URLSearchParams(id.slice(start + 1));
544
+ if (!params.has("vue")) return null;
545
+ const type = params.get("type");
546
+ if (!type || RESERVED_BLOCK_TYPES.has(type)) return null;
547
+ const index = Number.parseInt(params.get("index") ?? "0", 10);
548
+ if (!Number.isInteger(index) || index < 0) return null;
549
+ return {
550
+ type,
551
+ index
552
+ };
553
+ }
554
+ //#endregion
450
555
  //#region src/plugin/style-request.ts
451
556
  const STYLE_MARKER = ".__vize_style_";
452
557
  function normalizeInlineStyleModifiers(id) {
@@ -822,6 +927,7 @@ function generateOutputWithMap(compiled, options) {
822
927
  emitted.edit(`${emitted.code}\n${cssModuleSetup}`);
823
928
  }
824
929
  } else if (!ssr && compiled.css && !(isProduction && extractCss)) emitted.edit(prependInlineStyleInjection(emitted.code, compiled.css, compiled.scopeId));
930
+ if (filePath && exportsSfcMain && compiled.customBlocks?.length) emitted.edit(insertBeforeSfcMainDefaultExport(emitted.code, customBlockModuleCode(filePath, compiled.customBlocks)));
825
931
  if (!isProduction && isDev && hasExportDefault) {
826
932
  const effectiveHmrUpdateType = hmrUpdateType === "template-only" && !supportsTemplateOnlyHmr(emitted.code) ? "full-reload" : hmrUpdateType ?? "full-reload";
827
933
  emitted.edit(`${emitted.code}${generateHmrCode(compiled.scopeId, effectiveHmrUpdateType)}`);
@@ -992,6 +1098,7 @@ function getCompileOptionsForRequest(state, ssr, file) {
992
1098
  templateComments: !state.isProduction,
993
1099
  ...resolvePluginVueCompileOptions(mergedOptions ?? {})
994
1100
  };
1101
+ if (mergedOptions?.typeResolutionFallbackTsconfig !== void 0) options.typeResolutionFallbackTsconfig = mergedOptions.typeResolutionFallbackTsconfig;
995
1102
  if (mergedOptions?.nuxtPageMeta !== void 0) options.nuxtPageMeta = mergedOptions.nuxtPageMeta;
996
1103
  if (mergedOptions?.customElements !== void 0) options.customElements = mergedOptions.customElements;
997
1104
  if (mergedOptions?.mode !== void 0) options.mode = mergedOptions.mode;
@@ -1326,6 +1433,7 @@ function buildCompileFileOptions(filePath, options, scopeId = generateScopeId(fi
1326
1433
  ssr: options.ssr,
1327
1434
  vapor: options.vapor,
1328
1435
  ...options.nuxtPageMeta === void 0 ? {} : { nuxtPageMeta: options.nuxtPageMeta },
1436
+ ...options.typeResolutionFallbackTsconfig === void 0 ? {} : { typeResolutionFallbackTsconfig: options.typeResolutionFallbackTsconfig },
1329
1437
  ...options.whitespace === void 0 ? {} : { whitespace: options.whitespace },
1330
1438
  customRenderer: options.customRenderer ?? false,
1331
1439
  ...options.customElements === void 0 ? {} : { customElements: options.customElements },
@@ -1354,6 +1462,7 @@ function buildCompileBatchOptions(options) {
1354
1462
  ssr: options.ssr,
1355
1463
  vapor: options.vapor,
1356
1464
  ...options.nuxtPageMeta === void 0 ? {} : { nuxtPageMeta: options.nuxtPageMeta },
1465
+ ...options.typeResolutionFallbackTsconfig === void 0 ? {} : { typeResolutionFallbackTsconfig: options.typeResolutionFallbackTsconfig },
1357
1466
  ...options.whitespace === void 0 ? {} : { whitespace: options.whitespace },
1358
1467
  customRenderer: options.customRenderer ?? false,
1359
1468
  ...options.customElements === void 0 ? {} : { customElements: options.customElements },
@@ -1363,6 +1472,7 @@ function buildCompileBatchOptions(options) {
1363
1472
  experimentalStrictSlotChildren: options.experimentalStrictSlotChildren ?? false,
1364
1473
  experimentalServerScript: options.experimentalServerScript ?? false,
1365
1474
  includeStyles: true,
1475
+ includeCustomBlocks: true,
1366
1476
  includeMacroArtifacts: true,
1367
1477
  includeHashes: true,
1368
1478
  includeSourceMap: options.sourceMap,
@@ -1397,6 +1507,10 @@ var VizeSfcCompileError = class extends Error {
1397
1507
  function formatCompileErrorMessage(filePath, diagnostics) {
1398
1508
  return `[vize] Compilation failed in ${filePath}:\n${diagnostics.map((diagnostic) => ` - ${diagnostic}`).join("\n")}`;
1399
1509
  }
1510
+ function customBlockFields(blocks) {
1511
+ const customBlocks = normalizeCustomBlocks(blocks);
1512
+ return customBlocks.length > 0 ? { customBlocks } : {};
1513
+ }
1400
1514
  function normalizeStyleBlocks(styles, inlined) {
1401
1515
  if (!styles) return [];
1402
1516
  return styles.map((block) => ({
@@ -1420,6 +1534,7 @@ function compileFile(filePath, cache, options, source, diagnostics) {
1420
1534
  console.warn(`[vize] Warning in ${filePath}: ${warning}`);
1421
1535
  });
1422
1536
  const compiled = {
1537
+ ...result.typeProject ? { typeProject: result.typeProject } : {},
1423
1538
  source: content,
1424
1539
  code: result.code,
1425
1540
  ...result.map ? { map: result.map } : {},
@@ -1431,6 +1546,7 @@ function compileFile(filePath, cache, options, source, diagnostics) {
1431
1546
  scriptHash: result.scriptHash,
1432
1547
  macroArtifacts: result.macroArtifacts ?? [],
1433
1548
  styles: normalizeStyleBlocks(result.styles, resolved),
1549
+ ...customBlockFields(result.customBlocks),
1434
1550
  dependencies: [...resolved.dependencies, ...result.dependencies ?? []],
1435
1551
  ...result.moduleShape ? { moduleShape: result.moduleShape } : {}
1436
1552
  };
@@ -1500,6 +1616,8 @@ function compileBatch(files, cache, options) {
1500
1616
  if (fallback.css !== void 0) fileResult.css = fallback.css;
1501
1617
  fileResult.scopeId = fallback.scopeId;
1502
1618
  fileResult.hasScoped = fallback.hasScoped;
1619
+ delete fileResult.typeProject;
1620
+ if (fallback.typeProject !== void 0) fileResult.typeProject = fallback.typeProject;
1503
1621
  delete fileResult.macroArtifacts;
1504
1622
  if (fallback.macroArtifacts !== void 0) fileResult.macroArtifacts = fallback.macroArtifacts;
1505
1623
  delete fileResult.moduleShape;
@@ -1512,6 +1630,7 @@ function compileBatch(files, cache, options) {
1512
1630
  }
1513
1631
  for (const fileResult of result.results) {
1514
1632
  if (fileResult.errors.length === 0) cache.set(fileResult.path, {
1633
+ ...fileResult.typeProject ? { typeProject: fileResult.typeProject } : {},
1515
1634
  source: filesByPath.get(fileResult.path)?.source,
1516
1635
  code: fileResult.code,
1517
1636
  ...fileResult.map ? { map: fileResult.map } : {},
@@ -1523,6 +1642,7 @@ function compileBatch(files, cache, options) {
1523
1642
  scriptHash: fileResult.scriptHash,
1524
1643
  macroArtifacts: fileResult.macroArtifacts ?? [],
1525
1644
  styles: normalizeStyleBlocks(fileResult.styles, inlinedByPath.get(fileResult.path)),
1645
+ ...customBlockFields(fileResult.customBlocks),
1526
1646
  dependencies: [...inlinedByPath.get(fileResult.path)?.dependencies ?? [], ...fileResult.dependencies ?? []],
1527
1647
  ...fileResult.moduleShape ? { moduleShape: fileResult.moduleShape } : {}
1528
1648
  });
@@ -1638,10 +1758,11 @@ const EMPTY = Buffer.alloc(0);
1638
1758
  * Whether `module` may be persisted.
1639
1759
  *
1640
1760
  * Modules assembled from `src` imports depend on sibling files that this cache
1641
- * does not hash, so they are recompiled on every cold start instead.
1761
+ * does not hash. Project revisions belong to a single native process and cannot
1762
+ * register watches after a restart. Both kinds recompile on every cold start.
1642
1763
  */
1643
1764
  function isPersistablePrecompileModule(module) {
1644
- return !module.dependencies || module.dependencies.length === 0;
1765
+ return module.typeProject === void 0 && (!module.dependencies || module.dependencies.length === 0);
1645
1766
  }
1646
1767
  function isCompiledModule(value) {
1647
1768
  if (value === null || typeof value !== "object") return false;
@@ -2023,6 +2144,29 @@ async function prepareSfcSrcRequests(state, resolve, file, source) {
2023
2144
  (state.srcResolutions ??= /* @__PURE__ */ new Map()).set(file, await resolveSfcSrcRequests(file, requests, resolve));
2024
2145
  }
2025
2146
  //#endregion
2147
+ //#region src/plugin/type-project-watches.ts
2148
+ const watched = /* @__PURE__ */ new WeakMap();
2149
+ function resetTypeProjectWatches(cache) {
2150
+ watched.delete(cache);
2151
+ }
2152
+ function watchTypeProject(cache, context, addWatchFile, api = native) {
2153
+ if (!context || !addWatchFile) return;
2154
+ let projects = watched.get(cache);
2155
+ const knownRevision = projects?.get(context.root);
2156
+ const inputs = api.typeProjectInputs(context.root, context.revision, knownRevision);
2157
+ if (!inputs) throw new Error("[vize] TypeScript project changed while compiling; reload the component.");
2158
+ if (knownRevision === context.revision) return;
2159
+ for (const input of inputs) addWatchFile(input);
2160
+ if (!projects) {
2161
+ projects = /* @__PURE__ */ new Map();
2162
+ watched.set(cache, projects);
2163
+ }
2164
+ projects.set(context.root, context.revision);
2165
+ }
2166
+ function typeProjectDependencyRoots(cache, file, api = native) {
2167
+ return watched.has(cache) ? api.typeProjectOwners(file) : [];
2168
+ }
2169
+ //#endregion
2026
2170
  //#region src/plugin/precompile-run.ts
2027
2171
  /**
2028
2172
  * The pre-compilation pass.
@@ -2060,7 +2204,7 @@ function openCacheForRun(state, batchOptions) {
2060
2204
  /**
2061
2205
  * Pre-compile all Vue files matching scan patterns.
2062
2206
  */
2063
- async function compileAll(state, owners = [], resolve) {
2207
+ async function compileAll(state, owners = [], resolve, addWatchFile) {
2064
2208
  const startTime = performance.now();
2065
2209
  const sfcFiles = (await glob(state.scanPatterns, {
2066
2210
  cwd: state.root,
@@ -2177,6 +2321,7 @@ async function compileAll(state, owners = [], resolve) {
2177
2321
  }
2178
2322
  if (metadata) state.precompileMetadata.set(fileResult.path, metadata);
2179
2323
  const compiled = state.cache.get(fileResult.path);
2324
+ watchTypeProject(state.cache, fileResult.typeProject, addWatchFile);
2180
2325
  const sourceHash = sourceHashes.get(fileResult.path);
2181
2326
  if (fileResult.warnings.length > 0) cache.delete(fileResult.path);
2182
2327
  else if (compiled && sourceHash !== void 0) cache.set(fileResult.path, sourceHash, compiled);
@@ -3327,6 +3472,63 @@ function getVirtualStyleContent(block, options) {
3327
3472
  return transformCssVarsForPipeline(styleContent, options.scopeId, options.productionFilename);
3328
3473
  }
3329
3474
  //#endregion
3475
+ //#region src/plugin/custom-block-load.ts
3476
+ /**
3477
+ * Raw source for `?vue&type=<block>&index=N`, or `null` when `id` is not a
3478
+ * custom-block query. Style, script, and template queries stay on their own
3479
+ * paths. A `src` block reads that file and watches it.
3480
+ */
3481
+ function loadCustomBlock(state, id, options) {
3482
+ const query = parseCustomBlockQuery(id);
3483
+ if (!query) return null;
3484
+ const request = classifyVitePluginRequest(id);
3485
+ if (!request.isVueSfcPath) return null;
3486
+ const owner = vueOwnerPath(state, request.path);
3487
+ const block = getCompiledStyleSource(state, owner, !!options?.ssr)?.customBlocks?.[query.index];
3488
+ if (!block) return {
3489
+ code: "",
3490
+ map: null
3491
+ };
3492
+ if (block.src) return loadSrcBlock(state, owner, block, query.type, options?.addWatchFile);
3493
+ return {
3494
+ code: block.content,
3495
+ map: null
3496
+ };
3497
+ }
3498
+ function vueOwnerPath(state, requestPath) {
3499
+ const owner = requestPath.startsWith("/@fs/") ? requestPath.slice(4) : requestPath;
3500
+ if (owner.startsWith("/") && !fs.existsSync(owner)) {
3501
+ const projectPath = path.resolve(state.root, owner.slice(1));
3502
+ if (fs.existsSync(projectPath)) return projectPath;
3503
+ }
3504
+ return owner;
3505
+ }
3506
+ function loadSrcBlock(state, owner, block, blockType, addWatchFile) {
3507
+ const blockPath = path.resolve(path.dirname(owner), block.src ?? "");
3508
+ addWatchFile?.(blockPath);
3509
+ state.server?.watcher.add(blockPath);
3510
+ try {
3511
+ return {
3512
+ code: fs.readFileSync(blockPath, "utf8"),
3513
+ map: null
3514
+ };
3515
+ } catch {
3516
+ throw new Error(`[vize] Custom block <${blockType} src="${block.src}"> not found (resolved: ${blockPath}) in ${owner}`);
3517
+ }
3518
+ }
3519
+ //#endregion
3520
+ //#region src/plugin/dependency-watches.ts
3521
+ /**
3522
+ * Vite records a transform's addWatchFile calls as module imports. Compiler
3523
+ * inputs include absent config candidates and type-only files, so watch them
3524
+ * through the dev server's filesystem watcher. Build hooks keep Rollup watches.
3525
+ */
3526
+ function createDependencyWatch(server, addWatchFile) {
3527
+ return server ? (file) => {
3528
+ server.watcher.add(file);
3529
+ } : addWatchFile;
3530
+ }
3531
+ //#endregion
3330
3532
  //#region src/plugin/sfc-module.ts
3331
3533
  /**
3332
3534
  * The SFC main module: `load` serves the SFC text and `transform` compiles the
@@ -3426,8 +3628,16 @@ async function transformSfcModule(state, code, sfc, options = {}) {
3426
3628
  ...state,
3427
3629
  extractCss
3428
3630
  }, realPath, compiled);
3631
+ const watchDependency = createDependencyWatch(state.server, options.addWatchFile);
3632
+ try {
3633
+ watchTypeProject(state.cache, compiled.typeProject, watchDependency);
3634
+ } catch (error) {
3635
+ evictCompiledModule(cache, realPath);
3636
+ throw error;
3637
+ }
3638
+ if (sfc.nullPrefixed) options.addWatchFile?.(realPath);
3429
3639
  const dependencies = compiled.dependencies ?? [];
3430
- for (const watchFile of new Set(sfc.nullPrefixed ? [realPath, ...dependencies] : dependencies)) options.addWatchFile?.(watchFile);
3640
+ for (const dependency of new Set(dependencies)) watchDependency?.(dependency);
3431
3641
  const hasDelegated = hasDelegatedStyles(compiled);
3432
3642
  const outputOptions = {
3433
3643
  isProduction: state.isProduction,
@@ -3498,6 +3708,8 @@ function loadHook(state, id, loadOptions) {
3498
3708
  for (const css of state.collectedCss.values()) allCss += allCss ? `\n\n${css}` : css;
3499
3709
  return allCss;
3500
3710
  }
3711
+ const customBlock = loadCustomBlock(state, id, loadOptions);
3712
+ if (customBlock) return customBlock;
3501
3713
  const styleRequest = classifyVitePluginRequest(normalizeStyleVirtualId(id));
3502
3714
  if (styleRequest.isVueStyleQuery) {
3503
3715
  const isRootRelative = !!styleRequest.querySuffix && new URLSearchParams(styleRequest.querySuffix.slice(1)).has("vize-root-relative");
@@ -3672,6 +3884,24 @@ function invalidateModules(server, modules) {
3672
3884
  for (const module of modules) server.moduleGraph.invalidateModule(module);
3673
3885
  }
3674
3886
  //#endregion
3887
+ //#region src/plugin/custom-block-hmr.ts
3888
+ /** Module ids for one custom block, including Vite's `vue=` rewrite and `/@fs`. */
3889
+ function customBlockModuleIds(file, compiled) {
3890
+ const ids = [];
3891
+ for (const [index, block] of (compiled.customBlocks ?? []).entries()) {
3892
+ const query = customBlockQuery(block, index);
3893
+ const bare = `${file}?${query}`;
3894
+ const rewritten = `${file}?${query.replace(/^vue&/, "vue=&")}`;
3895
+ ids.push(bare, rewritten);
3896
+ if (bare.startsWith("/")) ids.push(`/@fs${bare}`, `/@fs${rewritten}`);
3897
+ }
3898
+ return ids;
3899
+ }
3900
+ /** Custom-block modules whose raw content a dev edit must send through again. */
3901
+ async function collectCustomBlockModules(server, file, compiled) {
3902
+ return collectModulesByFile(server, customBlockModuleIds(file, compiled));
3903
+ }
3904
+ //#endregion
3675
3905
  //#region src/plugin/hmr.ts
3676
3906
  const VIZE_COMPONENTS_CSS_BASENAME = "vize-components.css";
3677
3907
  const VIZE_COMPONENTS_CSS_FILE = `assets/${VIZE_COMPONENTS_CSS_BASENAME}`;
@@ -3686,15 +3916,21 @@ const VIZE_COMPONENTS_CSS_FILE = `assets/${VIZE_COMPONENTS_CSS_BASENAME}`;
3686
3916
  * index that answers it in constant time. See `compiled-module-cache.ts`.
3687
3917
  */
3688
3918
  function getVueFilesDependingOn(state, dependencyFile) {
3689
- const normalizedDependency = path.resolve(dependencyFile);
3919
+ const dependencies = [path.resolve(dependencyFile), ...typeProjectDependencyRoots(state.cache, dependencyFile)];
3690
3920
  const owners = /* @__PURE__ */ new Set();
3691
- for (const cache of [state.cache, state.ssrCache]) for (const vueFile of ownersOfDependency(cache, normalizedDependency)) owners.add(vueFile);
3692
- return [...owners];
3921
+ const clientOwners = /* @__PURE__ */ new Set();
3922
+ for (const cache of [state.cache, state.ssrCache]) for (const dependency of dependencies) for (const vueFile of ownersOfDependency(cache, dependency)) {
3923
+ owners.add(vueFile);
3924
+ if (cache === state.cache) clientOwners.add(vueFile);
3925
+ }
3926
+ return {
3927
+ owners: [...owners],
3928
+ clientOwners
3929
+ };
3693
3930
  }
3694
3931
  async function handleHotUpdateHook(state, ctx, options = {}) {
3695
3932
  const { file, server, read } = ctx;
3696
- const clientDependencyOwners = new Set(ownersOfDependency(state.cache, path.resolve(file)));
3697
- const dependencyOwners = getVueFilesDependingOn(state, file);
3933
+ const { owners: dependencyOwners, clientOwners: clientDependencyOwners } = getVueFilesDependingOn(state, file);
3698
3934
  if (dependencyOwners.length > 0) {
3699
3935
  const affectedModules = /* @__PURE__ */ new Set();
3700
3936
  for (const vueFile of dependencyOwners) {
@@ -3781,12 +4017,18 @@ async function handleHotUpdateHook(state, ctx, options = {}) {
3781
4017
  if (modules.size > 0) {
3782
4018
  state.pendingHmrUpdateTypes.set(file, updateType);
3783
4019
  invalidateModules(server, modules);
4020
+ const affected = new Set(modules);
3784
4021
  if (newCompiled.styles?.length && hasStyleChanges(prevCompiled, newCompiled)) {
3785
4022
  const styleModules = await collectStyleModules(server, file, newCompiled);
3786
4023
  invalidateModules(server, styleModules);
3787
- return [...new Set([...modules, ...styleModules])];
4024
+ for (const module of styleModules) affected.add(module);
3788
4025
  }
3789
- return [...modules];
4026
+ if (hasCustomBlockChanges(prevCompiled, newCompiled)) {
4027
+ const blockModules = await collectCustomBlockModules(server, file, newCompiled);
4028
+ invalidateModules(server, blockModules);
4029
+ for (const module of blockModules) affected.add(module);
4030
+ }
4031
+ return [...affected];
3790
4032
  }
3791
4033
  state.pendingHmrUpdateTypes.delete(file);
3792
4034
  } catch (e) {
@@ -4945,13 +5187,14 @@ function vize(options = {}, compilerDefaults = {}, hostContext) {
4945
5187
  installDevMiddleware(devServer, state);
4946
5188
  },
4947
5189
  async buildStart() {
5190
+ resetTypeProjectWatches(state.cache);
4948
5191
  state.viteResolveCache?.clear();
4949
5192
  if (!state.scanPatterns || state.scanPatterns.length === 0) return;
4950
5193
  try {
4951
5194
  await compileAll({
4952
5195
  ...state,
4953
5196
  extractCss: shouldExtractCssForBuild(state, this)
4954
- }, precompileInputOwners(this, precompileConfig), (request, importer) => this.resolve(request, importer, { skipSelf: true }));
5197
+ }, precompileInputOwners(this, precompileConfig), (request, importer) => this.resolve(request, importer, { skipSelf: true }), this.addWatchFile.bind(this));
4955
5198
  } catch (error) {
4956
5199
  if (!(error instanceof PrecompileDiagnosticsError)) throw error;
4957
5200
  state.logger.warn(`${error.message}\nStartup scan diagnostics are deferred until import.`);
@@ -4965,7 +5208,10 @@ function vize(options = {}, compilerDefaults = {}, hostContext) {
4965
5208
  });
4966
5209
  },
4967
5210
  load(id, loadOptions) {
4968
- return loadHook(state, id, { ssr: resolveHookSsr(this, loadOptions) });
5211
+ return loadHook(state, id, {
5212
+ ssr: resolveHookSsr(this, loadOptions),
5213
+ addWatchFile: (file) => this.addWatchFile(file)
5214
+ });
4969
5215
  },
4970
5216
  async transform(code, id, transformOptions) {
4971
5217
  return transformHook(state, code, id, {
@@ -1151,6 +1151,10 @@ type ModuleOutputInfo = {
1151
1151
  };
1152
1152
  //#endregion
1153
1153
  //#region src/sfc-types.d.ts
1154
+ interface TypeProjectContext {
1155
+ root: string;
1156
+ revision: string;
1157
+ }
1154
1158
  interface MacroArtifact {
1155
1159
  kind: string;
1156
1160
  name: string;
@@ -1160,6 +1164,15 @@ interface MacroArtifact {
1160
1164
  start: number;
1161
1165
  end: number;
1162
1166
  }
1167
+ /** Custom block handed to Vite. `type` is the native `blockType`. */
1168
+ interface CustomBlockInfo {
1169
+ type: string;
1170
+ content: string;
1171
+ src?: string | null;
1172
+ /** Non-boolean attributes keep their value; boolean attributes are `true`. */
1173
+ attrs: Record<string, string | true>;
1174
+ index: number;
1175
+ }
1163
1176
  interface StyleBlockInfo {
1164
1177
  /** Raw style content (uncompiled for preprocessor langs) */
1165
1178
  content: string;
@@ -1175,6 +1188,8 @@ interface StyleBlockInfo {
1175
1188
  index: number;
1176
1189
  }
1177
1190
  interface CompiledModule {
1191
+ /** Shared configuration authority; its watch inputs are registered once. */
1192
+ typeProject?: TypeProjectContext;
1178
1193
  /**
1179
1194
  * The SFC text this module was compiled from. A module answers only for this
1180
1195
  * text; the pre-compile cache stores its hash instead.
@@ -1198,6 +1213,11 @@ interface CompiledModule {
1198
1213
  macroArtifacts?: MacroArtifact[];
1199
1214
  /** Per-block style metadata extracted from the source SFC */
1200
1215
  styles?: StyleBlockInfo[];
1216
+ /**
1217
+ * Custom blocks. Absent on old cache entries and hand-built fixtures;
1218
+ * absence means the module emits no custom-block imports.
1219
+ */
1220
+ customBlocks?: CustomBlockInfo[];
1201
1221
  /** Files loaded through SFC `src` imports */
1202
1222
  dependencies?: string[];
1203
1223
  /**
@@ -1303,6 +1323,8 @@ interface VizeOptions extends ExperimentalPluginOptions {
1303
1323
  vapor?: boolean;
1304
1324
  /** Extract Nuxt page metadata; the Nuxt integration enables this explicitly. */
1305
1325
  nuxtPageMeta?: boolean;
1326
+ /** Fallback tsconfig for imported macro types when no user project owns the file. */
1327
+ typeResolutionFallbackTsconfig?: string;
1306
1328
  /**
1307
1329
  * Default output mode for `.jsx`/`.tsx` components without a `"use vue:*"`
1308
1330
  * directive. Distinct from `vapor` (which targets `.vue` SFCs): a project can
@@ -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-CuBwh3up.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-DRbVPh2U.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-DL5NF2G-.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-B3_BaqVE.mjs");
403
+ const { vize } = await import("./plugin-Dk8r3C7V.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.682.0",
3
+ "version": "0.684.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.682.0",
55
- "@vizejs/unplugin": "0.682.0",
54
+ "@vizejs/native": "0.684.0",
55
+ "@vizejs/unplugin": "0.684.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.682.0"
60
+ "vize": "0.684.0"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/node": "25.9.2",
@@ -1,2 +0,0 @@
1
- import { t as vize } from "./plugin-DeTv2aMw.mjs";
2
- export { vize };