jiti.d.ts 888 B

1234567891011121314151617181920
  1. import { Module } from "module";
  2. import { TransformOptions, JITIOptions, JITIImportOptions } from "./types";
  3. export type { JITIOptions, TransformOptions } from "./types";
  4. type Require = typeof require;
  5. type Module = typeof module;
  6. type ModuleCache = Record<string, Module>;
  7. export type EvalModuleOptions = Partial<{
  8. id: string;
  9. filename: string;
  10. ext: string;
  11. cache: ModuleCache;
  12. }>;
  13. export interface JITI extends Require {
  14. transform: (opts: TransformOptions) => string;
  15. register: () => () => void;
  16. evalModule: (source: string, options?: EvalModuleOptions) => unknown;
  17. /** @experimental Behavior of `jiti.import` might change in the future. */
  18. import: (id: string, importOptions: JITIImportOptions) => Promise<unknown>;
  19. }
  20. export default function createJITI(_filename: string, opts?: JITIOptions, parentModule?: Module, parentCache?: ModuleCache): JITI;