context.d.ts 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. /// <reference types="node" />
  2. /// <reference types="node" />
  3. import { EdgeRuntime } from 'next/dist/compiled/edge-runtime';
  4. import type { EdgeFunctionDefinition } from '../../../build/webpack/plugins/middleware-plugin';
  5. /**
  6. * For a given path a context, this function checks if there is any module
  7. * context that contains the path with an older content and, if that's the
  8. * case, removes the context from the cache.
  9. */
  10. export declare function clearModuleContext(path: string, content: Buffer | string): void;
  11. interface ModuleContextOptions {
  12. moduleName: string;
  13. onWarning: (warn: Error) => void;
  14. useCache: boolean;
  15. env: string[];
  16. distDir: string;
  17. edgeFunctionEntry: Pick<EdgeFunctionDefinition, 'assets' | 'wasm'>;
  18. }
  19. /**
  20. * For a given module name this function will get a cached module
  21. * context or create it. It will return the module context along
  22. * with a function that allows to run some code from a given
  23. * filepath within the context.
  24. */
  25. export declare function getModuleContext(options: ModuleContextOptions): Promise<{
  26. evaluateInContext: (filepath: string) => void;
  27. runtime: EdgeRuntime;
  28. paths: Map<string, string>;
  29. warnedEvals: Set<string>;
  30. }>;
  31. export {};