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(), ], });
view source

Declarations
#

VitePluginSvelteDocinfoOptions
#

vite.ts view source

VitePluginSvelteDocinfoOptions import type {VitePluginSvelteDocinfoOptions} from 'svelte-docinfo/vite.js';

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; an absolute pattern inside the root relativizes, an out-of-root one throws — see normalizeIncludePatterns).

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.

Explicit patterns also widen the source scope: their static bases join sourceOptions.sourcePaths (see widenSourcePathsForInclude), so include-discovered files outside the configured source paths still emit modules — and the watcher tracks their changes. A pattern with no static base ('**\/*.ts', a literal root file) scopes the whole project root as source and logs an info line; an out-of-root base throws.

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 string[]

exclude?

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

Takes precedence over sourceOptions.exclude (no merge between the two). An array replaces the default patterns wholesale — the test, spec, and internal/ filters are dropped unless re-included — while the callback form extends them without restating them ((defaults) => [...defaults, '**\/*.gen.ts'] — see ExcludeOption). The callback always receives the built-in defaults, even when sourceOptions.exclude is also set (that value is superseded whole). The always-on baseline (node_modules + dot-directories below a matched source path) applies beneath it and is unaffected by overrides.

type ExcludeOption

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

default true

discovery?

Discovery strategy for source files.

type Discovery

default 'auto'

see also

distDir?

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

type string

default 'dist'

sourceOptions?

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

type SourceOptionsOverrides

onDuplicates?

Behavior when duplicate declaration names are found across modules.

type OnDuplicates

hmrDebounceMs?

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

type number

default 100

Depends on
#