import { IdentifierOption } from "@sanity/vanilla-extract-integration"; import { EnvironmentModuleNode, Plugin, UserConfig } from "vite"; /** @public */ interface ProcessedVanillaFile { /** The serialized JS module: virtual CSS imports followed by the evaluated exports. */ source: string; /** Files the `.css.ts` module (transitively) depends on. */ watchFiles: Set; } /** @public */ interface Compiler { /** * Evaluates a `.css.ts` module (through the internal Vite server, cached in its module graph) * and returns its serialized JS along with the files it depends on. The extracted CSS is * retrievable per file through {@link Compiler.getCssForFile}. */ processVanillaFile(filePath: string, options?: { outputCss?: boolean; }): Promise; /** The extracted CSS of a previously processed `.css.ts` file, if any. */ getCssForFile(filePath: string): { filePath: string; css: string; } | undefined; /** * All extracted CSS known to the compiler, e.g. to inline into HTML during dev SSR * (`mode: 'inlineCssInDev'`). * * Ordering contract (matching upstream `@vanilla-extract/compiler`): per-file CSS is * concatenated in first-evaluation order — within a single compilation that follows the * module graph (dependencies before their importers), across compilations it follows the * order the dev server first requested each `.css.ts` module. The order is stable across * recompiles (re-setting a key keeps its Map position). It is a FOUC stopgap, not the * authoritative cascade: the same CSS also loads through Vite's CSS pipeline in module-graph * order, and those later style tags win over the head-prepended inline block for * equal-specificity rules. */ getAllCss(): string; /** * The transitive importer tree of a file, from the compiler's own module graph (the consuming * dev server's graph gets rewritten by the plugin transform, so it can't reconstruct the * original chain). Stops at processed vanilla-extract module boundaries. */ findImporterTree(filePath: string, transformedVanillaModules: ReadonlySet): Promise>; /** * Invalidates every non-`node_modules` module in the compiler's module graph and runner * cache, forcing the next {@link Compiler.processVanillaFile} to re-evaluate. The extracted * CSS of previous compilations intentionally stays available (like upstream * `@vanilla-extract/compiler`) until it's replaced by the re-evaluation: already-served * modules keep importing their virtual CSS, so dropping it would break those loads. */ invalidateAllModules(): Promise; close(): Promise; } /** @public */ interface CreateCompilerOptions { root: string; identifiers?: IdentifierOption; /** * Maps a `.css.ts` file path to the virtual CSS module specifier imported by its compiled JS. */ cssImportSpecifier?: (filePath: string) => string; /** Vite config forwarded to the internal compiler server (resolve options, plugins, etc). */ viteConfig?: UserConfig; /** * The compiler watches the files it evaluates and invalidates its caches on change. Disable * during production builds, where nothing changes mid-build. * @defaultValue true */ enableFileWatcher?: boolean; } /** @public */ export declare function createCompiler({ root, identifiers, cssImportSpecifier, viteConfig, enableFileWatcher }: CreateCompilerOptions): Compiler; /** * Decides which of the consumer's Vite plugins are forwarded to the internal compiler server * that evaluates the `.css.ts` modules. * @public */ export type PluginFilter = (filterProps: { /** The name of the plugin. */ name: string; /** * The `mode` Vite is running in. * @see https://vite.dev/guide/env-and-mode.html#modes */ mode: string; }) => boolean; /** * Options for {@link vanillaExtractPlugin}. * @public */ export interface Options { /** * Different formatting of identifiers (e.g. class names, keyframes, CSS Vars, etc). * @defaultValue `'short'` when `mode` is `'production'`, `'debug'` otherwise */ identifiers?: IdentifierOption; /** * Which of the consumer's Vite plugins are re-instantiated inside the compiler server that * evaluates the `.css.ts` modules. By default **no** plugins are forwarded (and the * filtering work is skipped entirely) — most plugins don't affect `.css.ts` evaluation, and * forwarding them would run every transform twice. Vite's own options (including the * built-in * [`resolve.tsconfigPaths`](https://vite.dev/config/shared-options#resolve-tsconfigpaths), * which replaces the `vite-tsconfig-paths` plugin on Vite 8) still apply to the compiler * server through the forwarded config. */ pluginFilter?: PluginFilter; /** * How the extracted CSS reaches the page during development: * * - `'emitCss'` (the default) serves each `.css.ts` module's CSS as a virtual `.vanilla.css` * module through Vite's CSS pipeline. * - `'inlineCssInDev'` additionally inlines all extracted CSS into a `