jiti.d.ts 919 B

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