import type { Plugin } from 'vite'; /** * Builds the plugin that resolves a package's `source` export condition, for a package whose files sit outside * every `node_modules`. * * The condition cannot be emitted as a `resolve.conditions` entry instead: Vitest turns the server environment's * conditions into `--conditions` flags on the worker process, where Node applies them to every package it * resolves natively. Node refuses to strip types from a file under `node_modules`, so a dependency declaring a * TypeScript `source` entry fails to load as soon as the condition reaches that far. * * Resolving here instead keeps the condition inside Vite, which transforms what it resolves. A package under * `node_modules` resolves through its remaining conditions, whatever its `exports` map declares. */ export declare function createSourceResolutionPlugin(): Plugin; /** What a resolution needs beyond the specifier and its importer: the resolving environment, and the caches. */ export interface SourceResolutionContext { /** The Vite environment resolving the specifier, which decides the environment-specific condition. */ environmentName: string; /** Parsed manifests, keyed by package directory. Absent from a caller that resolves once. */ manifests?: Map; /** Package directories, keyed by specifier and importer directory. Absent from a caller that resolves once. */ packageDirs?: Map; } /** * Resolves a bare specifier to the file that its package's `source` condition names, or nothing where the condition * does not reach it. * * Answers a bare specifier naming a package whose real directory sits outside every `node_modules`. Every other * specifier returns nothing -- such as a relative or absolute path, a virtual module, a builtin, or a package under * `node_modules` -- so Vite resolves the specifier through its own conditions. Throws where the condition reaches no * file, because falling through to the build output is the staleness that resolving from source exists to prevent, * and nothing in a run reports it. * * A query or hash suffix is split off before the `exports` lookup and re-appended to the resolved path, as Vite * does, so `pkg/icon.svg?raw` matches the `./icon.svg` entry and still reaches the plugin that reads the suffix. */ export declare function resolveSourceTarget(specifier: string, importer: string | undefined, context: SourceResolutionContext): string | undefined;