vite.ts

Vite plugin for svelte-docinfo.

Drives a long-lived AnalysisSession against a debounce-batched watcher. Every file change funnels into a pendingChanges Map and flushes via one setFiles + one query per debounce window — multi-file editor saves collapse to a single re-analysis instead of N serialized round-trips.

The plugin no longer maintains a fileCache.content mirror — setFile returns {changed: boolean} so HMR invalidation reacts to that flag directly. session.list() / session.has() cover owned-set introspection.

Consumers import the analysis result:

import {modules, diagnostics} from 'virtual:svelte-docinfo';

For TypeScript support, add to your app.d.ts:

/// <reference types="svelte-docinfo/virtual-svelte-docinfo.js" />

@example

// vite.config.ts import svelteDocinfo from 'svelte-docinfo/vite.js'; export default defineConfig({ plugins: [ sveltekit(), svelteDocinfo(), ], });

Declarations
#

view source

VitePluginSvelteDocinfoOptions
#

vite.ts view source

VitePluginSvelteDocinfoOptions

Options for the svelteDocinfo Vite plugin.

projectRoot

Absolute path to project root directory. Defaults to Vite's resolved config.root.

type string

include

Glob patterns to include (relative to projectRoot).

When provided under the default discovery: 'auto', collapses the chain to glob (exports discovery is skipped). Combining include with discovery: 'exports' throws at config-resolve time — exports mode has no concept of include patterns.

When omitted, the glob fallback derives an include from sourceOptions.sourcePaths via deriveIncludePatterns, so custom sourcePaths survive the fallback instead of silently defaulting to src/lib.

type Array<string>

exclude

Glob patterns to exclude, applied at both discovery and analysis time.

When provided, fully replaces sourceOptions.exclude (no array merge) — the default test and spec filters are dropped unless re-included explicitly.

type Array<string>

resolveDependencies

Whether to resolve import dependencies.

When false, the session's resolver returns null for every specifier, so module dependencies/dependents stay empty.

type boolean

discovery

Discovery strategy for source files.

distDir

Dist directory name relative to project root, used for exports-based discovery.

type string

sourceOptions

Partial overrides for default source options (SvelteKit src/lib layout).

type Partial<SourceOptionsDefaults>

onDuplicates

Behavior when duplicate declaration names are found across modules.

hmrDebounceMs

HMR debounce delay in milliseconds. Coalesces rapid file changes during dev.

type number

Depends on
#