Skip to content

Commit

Permalink
fix(compiler): update memory cache for compiler using received file c…
Browse files Browse the repository at this point in the history
…ontent (#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.
  • Loading branch information
TexKiller authored Jan 2, 2022
1 parent 285e942 commit e4d9541
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/compiler/ts-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e4d9541

Please sign in to comment.