/
ts-jest-compiler.ts
23 lines (17 loc) · 977 Bytes
/
ts-jest-compiler.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import type { TransformedSource } from '@jest/transform'
import type { ConfigSet } from '../legacy/config/config-set'
import type { CompilerInstance, StringMap, TsJestCompileOptions } from '../types'
import { TsCompiler } from './ts-compiler'
export class TsJestCompiler implements CompilerInstance {
private readonly _compilerInstance: CompilerInstance
constructor(configSet: ConfigSet, runtimeCacheFS: StringMap) {
// Later we can add swc/esbuild or other typescript compiler instance here
this._compilerInstance = new TsCompiler(configSet, runtimeCacheFS)
}
getResolvedModules(fileContent: string, fileName: string, runtimeCacheFS: StringMap): string[] {
return this._compilerInstance.getResolvedModules(fileContent, fileName, runtimeCacheFS)
}
getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions): TransformedSource {
return this._compilerInstance.getCompiledOutput(fileContent, fileName, options)
}
}