jiti.d.ts 950 B

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