|
- import { Plugin } from 'vite';
- import { FilterPattern } from '@rollup/pluginutils';
- import { Awaitable } from '@antfu/utils';
-
- interface TransformInfo {
- name: string;
- result: string;
- start: number;
- end: number;
- order?: string;
- }
- interface ModuleInfo {
- id: string;
- plugins: string[];
- deps: string[];
- virtual: boolean;
- }
- interface ModulesList {
- root: string;
- modules: ModuleInfo[];
- ssrModules: ModuleInfo[];
- }
- interface ModuleTransformInfo {
- resolvedId: string;
- transforms: TransformInfo[];
- }
- interface PluginMetricInfo {
- name: string;
- enforce?: string;
- transform: {
- invokeCount: number;
- totalTime: number;
- };
- resolveId: {
- invokeCount: number;
- totalTime: number;
- };
- }
- interface RPCFunctions {
- list(): Awaitable<ModulesList>;
- getIdInfo(id: string, ssr: boolean, clear?: boolean): Awaitable<ModuleTransformInfo>;
- resolveId(id: string, ssr: boolean): Awaitable<string>;
- clear(id: string, ssr: boolean): Awaitable<void>;
- getPluginMetrics(ssr: boolean): Awaitable<PluginMetricInfo[]>;
- }
-
- interface Options {
- /**
- * Enable the inspect plugin in dev mode (could be some performance overhead)
- *
- * @default true
- */
- dev?: boolean;
- /**
- * Enable the inspect plugin in build mode, and output the report to `.vite-inspect`
- *
- * @default false
- */
- build?: boolean;
- /**
- * @deprecated use `dev` or `build` option instead.
- */
- enabled?: boolean;
- /**
- * Directory for build inspector UI output
- * Only work in build mode
- *
- * @default '.vite-inspect'
- */
- outputDir?: string;
- /**
- * Filter for modules to be inspected
- */
- include?: FilterPattern;
- /**
- * Filter for modules to not be inspected
- */
- exclude?: FilterPattern;
- /**
- * Base URL for inspector UI
- *
- * @default read from Vite's config
- */
- base?: string;
- }
- interface ViteInspectAPI {
- rpc: RPCFunctions;
- }
- declare function PluginInspect(options?: Options): Plugin;
- declare namespace PluginInspect {
- var getViteInspectAPI: (plugins: Plugin[]) => ViteInspectAPI | undefined;
- }
-
- export { Options, ViteInspectAPI, PluginInspect as default };
|