ScriptTransformer.d.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233
  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, TransformResult } from './types';
  9. export default class ScriptTransformer {
  10. private _cache;
  11. private _config;
  12. private _transformCache;
  13. private _transformConfigCache;
  14. constructor(config: Config.ProjectConfig);
  15. private _getCacheKey;
  16. private _getFileCachePath;
  17. private _getTransformPath;
  18. private _getTransformer;
  19. private _instrumentFile;
  20. preloadTransformer(filepath: Config.Path): void;
  21. transformSource(filepath: Config.Path, content: string, instrument: boolean, supportsDynamicImport?: boolean, supportsStaticESM?: boolean): TransformResult;
  22. private _transformAndBuildScript;
  23. transform(filename: Config.Path, options: Options, fileSource?: string): TransformResult;
  24. transformJson(filename: Config.Path, options: Options, fileSource: string): string;
  25. requireAndTranspileModule<ModuleType = unknown>(moduleName: string, callback?: (module: ModuleType) => void): ModuleType;
  26. requireAndTranspileModule<ModuleType = unknown>(moduleName: string, callback?: (module: ModuleType) => Promise<void>): Promise<ModuleType>;
  27. /**
  28. * @deprecated use `this.shouldTransform` instead
  29. */
  30. private _shouldTransform;
  31. shouldTransform(filename: Config.Path): boolean;
  32. }
  33. export declare function createTranspilingRequire(config: Config.ProjectConfig): <TModuleType = unknown>(resolverPath: string, applyInteropRequireDefault?: boolean) => TModuleType;