From e4d9541f262ca14cb25563c757c0f2345dbf5c51 Mon Sep 17 00:00:00 2001 From: TexKiller Date: Sun, 2 Jan 2022 06:27:28 -0300 Subject: [PATCH] fix(compiler): update memory cache for compiler using received file content (#3194) 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