Skip to content

Commit 69456ca

Browse files
committed
make filename cache key relative to rootDir
1 parent e9afe00 commit 69456ca

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

packages/babel-jest/src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010

1111
import type {Path, ProjectConfig} from 'types/Config';
12-
import type {TransformOptions} from 'types/Transform';
12+
import type {CacheKeyOptions, TransformOptions} from 'types/Transform';
1313

1414
import crypto from 'crypto';
1515
import fs from 'fs';
@@ -82,15 +82,15 @@ const createTransformer = (options: any) => {
8282
fileData: string,
8383
filename: Path,
8484
configString: string,
85-
{instrument}: TransformOptions,
85+
{instrument, rootDir}: CacheKeyOptions,
8686
): string {
8787
return crypto
8888
.createHash('md5')
8989
.update(THIS_FILE)
9090
.update('\0', 'utf8')
9191
.update(fileData)
9292
.update('\0', 'utf8')
93-
.update(filename)
93+
.update(path.relative(rootDir, filename))
9494
.update('\0', 'utf8')
9595
.update(configString)
9696
.update('\0', 'utf8')

packages/jest-runtime/src/script_transformer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class ScriptTransformer {
7777
transformer.getCacheKey(fileData, filename, configString, {
7878
instrument,
7979
mapCoverage,
80+
rootDir: this._config.rootDir,
8081
}),
8182
)
8283
.update(CACHE_VERSION)

types/Transform.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export type TransformOptions = {|
2828
export type CacheKeyOptions = {|
2929
instrument: boolean,
3030
mapCoverage: boolean,
31+
rootDir: string,
3132
|};
3233

3334
export type Transformer = {|

0 commit comments

Comments
 (0)