Skip to content

Commit e4d9541

Browse files
authored
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.
1 parent 285e942 commit e4d9541

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/compiler/ts-compiler.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ export class TsCompiler implements TsCompilerInstance {
386386
if (!hit) {
387387
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
388388
this._fileVersionCache!.set(fileName, 1)
389+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
390+
this._fileContentCache!.set(fileName, contents)
389391
shouldIncrementProjectVersion = true
390392
} else {
391393
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion

0 commit comments

Comments
 (0)