svelte_config_cache.ts

view source

Declarations
#

7 declarations

SVELTE_CONFIG_CACHE_FILENAME
#

svelte_config_cache_read
#

svelte_config_cache.ts view source

(stamps: SvelteConfigCacheStamps, dir?: string): SvelteConfigCache | null import {svelte_config_cache_read} from '@fuzdev/gro/svelte_config_cache.js';

Reads the cache and returns it only if every input still matches stamps. Every kind of miss - absent, corrupt, wrong version, stale - reads the same to the caller, which resolves the config and rewrites.

stamps

dir

type string
default process.cwd()

returns

SvelteConfigCache | null

svelte_config_cache_stamps
#

svelte_config_cache.ts view source

(dir?: string): SvelteConfigCacheStamps import {svelte_config_cache_stamps} from '@fuzdev/gro/svelte_config_cache.js';

Snapshots the state of the cache inputs in dir.

Taken by the caller *before* resolving the config, not inside svelte_config_cache_write afterwards: a config edited mid-resolution should leave a stamp that no longer matches, so the next invocation resolves again. Stamping afterwards would pair the old alias with the new state and serve it as fresh.

dir

type string
default process.cwd()

returns

SvelteConfigCacheStamps

SVELTE_CONFIG_CACHE_VERSION
#

svelte_config_cache.ts view source

1 import {SVELTE_CONFIG_CACHE_VERSION} from '@fuzdev/gro/svelte_config_cache.js';

Bump when SvelteConfigCache's shape changes, or when the meaning of a field does, so caches written by an older Gro self-invalidate instead of being read as the new shape.

svelte_config_cache_write
#

svelte_config_cache.ts view source

(stamps: SvelteConfigCacheStamps, read: Pick<SvelteConfigCache, "alias" | "svelte_config_found">, dir?: string): void import {svelte_config_cache_write} from '@fuzdev/gro/svelte_config_cache.js';

Writes the cache for the config that stamps was taken before resolving.

Best effort - a cache that can't be written just means the next invocation resolves again, so a read-only or otherwise unwritable project directory costs speed and nothing else.

stamps

read

what resolving the config produced

type Pick<SvelteConfigCache, "alias" | "svelte_config_found">

dir

type string
default process.cwd()

returns

void

SvelteConfigCache
#

svelte_config_cache.ts view source

SvelteConfigCache import type {SvelteConfigCache} from '@fuzdev/gro/svelte_config_cache.js';

version

type number

stamps

type SvelteConfigCacheStamps

alias

The alias of a ParsedSvelteConfig.

type Record<string, string>

svelte_config_found

false when the Vite config resolved but configured no Svelte plugin, so a cached read can repeat the warning a fresh load would have emitted instead of going quiet about it.

type boolean

SvelteConfigCacheStamps
#

svelte_config_cache.ts view source

SvelteConfigCacheStamps import type {SvelteConfigCacheStamps} from '@fuzdev/gro/svelte_config_cache.js';

The mtime and size of each cache input, or null for one that doesn't exist. Absence is recorded rather than omitted so that *adding* a config file invalidates too.

[key: string]

type string | null

Depends on
#

Imported by
#