ScriptTransformer.d.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. import type { Config } from '@jest/types';
  8. import type { Options, ReducedTransformOptions, RequireAndTranspileModuleOptions, StringMap, TransformResult } from './types';
  9. declare class ScriptTransformer {
  10. private readonly _config;
  11. private readonly _cacheFS;
  12. private readonly _cache;
  13. private readonly _transformCache;
  14. private _transformsAreLoaded;
  15. constructor(_config: Config.ProjectConfig, _cacheFS: StringMap);
  16. private _buildCacheKeyFromFileInfo;
  17. private _getCacheKey;
  18. private _getCacheKeyAsync;
  19. private _createFolderFromCacheKey;
  20. private _getFileCachePath;
  21. private _getFileCachePathAsync;
  22. private _getTransformPath;
  23. loadTransformers(): Promise<void>;
  24. private _getTransformer;
  25. private _instrumentFile;
  26. private _buildTransformResult;
  27. transformSource(filepath: Config.Path, content: string, options: ReducedTransformOptions): TransformResult;
  28. transformSourceAsync(filepath: Config.Path, content: string, options: ReducedTransformOptions): Promise<TransformResult>;
  29. private _transformAndBuildScriptAsync;
  30. private _transformAndBuildScript;
  31. transformAsync(filename: Config.Path, options: Options, fileSource?: string): Promise<TransformResult>;
  32. transform(filename: Config.Path, options: Options, fileSource?: string): TransformResult;
  33. transformJson(filename: Config.Path, options: Options, fileSource: string): string;
  34. requireAndTranspileModule<ModuleType = unknown>(moduleName: string, callback?: (module: ModuleType) => void | Promise<void>, options?: RequireAndTranspileModuleOptions): Promise<ModuleType>;
  35. shouldTransform(filename: Config.Path): boolean;
  36. }
  37. export declare function createTranspilingRequire(config: Config.ProjectConfig): Promise<(<TModuleType = unknown>(resolverPath: string, applyInteropRequireDefault?: boolean) => Promise<TModuleType>)>;
  38. export declare type TransformerType = ScriptTransformer;
  39. export declare function createScriptTransformer(config: Config.ProjectConfig, cacheFS?: StringMap): Promise<TransformerType>;
  40. export {};