From ef6c6722f607af10dd68015a2511d470930c0faf Mon Sep 17 00:00:00 2001 From: TexKiller Date: Sat, 1 Jan 2022 23:08:55 -0300 Subject: [PATCH] Fix: transform using received file content The ts-jest transform is currently ignoring the file content it receives until there is already a hit in the memory cache. That prevents us from doing things like chaining transforms (see https://github.com/anc95/jest-chain-transform), as ts-jest will just read the original file from disk and ignore the transformation. The changes I'm proposing were enough to resolve the issue for my use case. I haven't done extensive research into it, but it seems pretty straightforward. --- src/compiler/ts-compiler.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/ts-compiler.ts b/src/compiler/ts-compiler.ts index 6849e17ba9..7790e4b54e 100644 --- a/src/compiler/ts-compiler.ts +++ b/src/compiler/ts-compiler.ts @@ -386,6 +386,8 @@ export class TsCompiler implements TsCompilerInstance { if (!hit) { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion this._fileVersionCache!.set(fileName, 1) + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + this._fileContentCache!.set(fileName, contents) shouldIncrementProjectVersion = true } else { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion