版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

95 lines
2.2 KiB

  1. import { Plugin } from 'vite';
  2. import { FilterPattern } from '@rollup/pluginutils';
  3. import { Awaitable } from '@antfu/utils';
  4. interface TransformInfo {
  5. name: string;
  6. result: string;
  7. start: number;
  8. end: number;
  9. order?: string;
  10. }
  11. interface ModuleInfo {
  12. id: string;
  13. plugins: string[];
  14. deps: string[];
  15. virtual: boolean;
  16. }
  17. interface ModulesList {
  18. root: string;
  19. modules: ModuleInfo[];
  20. ssrModules: ModuleInfo[];
  21. }
  22. interface ModuleTransformInfo {
  23. resolvedId: string;
  24. transforms: TransformInfo[];
  25. }
  26. interface PluginMetricInfo {
  27. name: string;
  28. enforce?: string;
  29. transform: {
  30. invokeCount: number;
  31. totalTime: number;
  32. };
  33. resolveId: {
  34. invokeCount: number;
  35. totalTime: number;
  36. };
  37. }
  38. interface RPCFunctions {
  39. list(): Awaitable<ModulesList>;
  40. getIdInfo(id: string, ssr: boolean, clear?: boolean): Awaitable<ModuleTransformInfo>;
  41. resolveId(id: string, ssr: boolean): Awaitable<string>;
  42. clear(id: string, ssr: boolean): Awaitable<void>;
  43. getPluginMetrics(ssr: boolean): Awaitable<PluginMetricInfo[]>;
  44. }
  45. interface Options {
  46. /**
  47. * Enable the inspect plugin in dev mode (could be some performance overhead)
  48. *
  49. * @default true
  50. */
  51. dev?: boolean;
  52. /**
  53. * Enable the inspect plugin in build mode, and output the report to `.vite-inspect`
  54. *
  55. * @default false
  56. */
  57. build?: boolean;
  58. /**
  59. * @deprecated use `dev` or `build` option instead.
  60. */
  61. enabled?: boolean;
  62. /**
  63. * Directory for build inspector UI output
  64. * Only work in build mode
  65. *
  66. * @default '.vite-inspect'
  67. */
  68. outputDir?: string;
  69. /**
  70. * Filter for modules to be inspected
  71. */
  72. include?: FilterPattern;
  73. /**
  74. * Filter for modules to not be inspected
  75. */
  76. exclude?: FilterPattern;
  77. /**
  78. * Base URL for inspector UI
  79. *
  80. * @default read from Vite's config
  81. */
  82. base?: string;
  83. }
  84. interface ViteInspectAPI {
  85. rpc: RPCFunctions;
  86. }
  87. declare function PluginInspect(options?: Options): Plugin;
  88. declare namespace PluginInspect {
  89. var getViteInspectAPI: (plugins: Plugin[]) => ViteInspectAPI | undefined;
  90. }
  91. export { Options, ViteInspectAPI, PluginInspect as default };