import type { Adapter } from '@sveltejs/kit'; import type { Plugin } from 'vite'; /** * The subset of SvelteKit's configuration that this SDK reads, in a shape that's normalized * across SvelteKit majors: * * - SvelteKit 2 keeps its options nested under `kit` in `svelte.config.js` * - SvelteKit 3 removed `svelte.config.js` and passes a flat config to the `sveltekit()` Vite plugin * * We always work with the flat shape (see {@link normalizeKitConfig}). */ export type ResolvedKitConfig = { adapter?: Adapter; outDir?: string; /** File extensions SvelteKit treats as modules, `['.js', '.ts']` by default. */ moduleExtensions?: string[]; files?: { hooks?: { client?: string; server?: string; }; }; paths?: { base?: '' | `/${string}`; }; /** SvelteKit 3 (>= 3.0.0-next.8) promoted native tracing out of `experimental` */ tracing?: { server?: boolean; }; /** SvelteKit 2.31+ and early SvelteKit 3 prereleases nest native tracing here */ experimental?: { tracing?: { server?: boolean; }; }; }; export type KitConfigResolver = { /** * Register this before the plugins that call {@link KitConfigResolver.get}. * * Never `await` {@link KitConfigResolver.get} from a `config` hook: `sveltekit()` is an async * factory in both majors, so the plugin array Vite passes to `config` still holds an unresolved * promise where the SvelteKit plugin will be - it's only findable in `configResolved`. Awaiting * from `config` blocks the very phase that would resolve it, and the build hangs. */ plugin: Plugin; get: () => Promise; }; /** * Creates a Vite plugin that resolves the SvelteKit config once, plus a getter for other plugins * to await it. * * The config comes from the `sveltekit()` Vite plugin's `api.options` rather than from * `svelte.config.js`: SvelteKit 3 removed that file, and 2.66+ lets users move their config into * `vite.config.js`. Loading `svelte.config.js` stays as the fallback, and isn't just an edge case: * `api.options` only exists from 2.62 on, so every older 2.x app still resolves through the file, * as do setups where the SvelteKit plugin isn't registered at all. * * Not `@sveltejs/load-config`: it re-resolves the `vite.config.js` we're being constructed by, so * it ends up waiting on itself and hangs - and it reads this same `api.options` to begin with. */ export declare function createKitConfigResolver(): KitConfigResolver; /** * Picks the SvelteKit options off the SvelteKit Vite plugin, if it's registered. * Exported only for testing. */ export declare function findKitConfigInPlugins(plugins: unknown): ResolvedKitConfig | undefined; /** * Flattens a SvelteKit 2 config (`{ kit: { ... } }`) to the SvelteKit 3 shape (`{ ... }`) and makes * the paths we read relative and `/`-separated. * * SvelteKit resolves `outDir` and `files.hooks.*` against the cwd before exposing them on * `api.options`, but everything downstream matches them as relative paths: the hooks file regexp * against Vite module ids, the injected output dir against stack frames from another machine. * * Exported only for testing. */ export declare function normalizeKitConfig(config: ResolvedKitConfig & { kit?: ResolvedKitConfig; }): ResolvedKitConfig; /** * Whether SvelteKit's native server-side tracing is enabled. If it is, we must not add our own * server-side instrumentation on top of SvelteKit's, or we'd emit duplicate spans. */ export declare function isNativeServerTracingEnabled(kitConfig: ResolvedKitConfig): boolean; //# sourceMappingURL=kitConfig.d.ts.map