diff --git a/packages/babel-jest/src/index.js b/packages/babel-jest/src/index.js index 331bc793e76f..3751e146f08b 100644 --- a/packages/babel-jest/src/index.js +++ b/packages/babel-jest/src/index.js @@ -9,7 +9,7 @@ */ import type {Path, ProjectConfig} from 'types/Config'; -import type {TransformOptions} from 'types/Transform'; +import type {CacheKeyOptions, TransformOptions} from 'types/Transform'; import crypto from 'crypto'; import fs from 'fs'; @@ -82,7 +82,7 @@ const createTransformer = (options: any) => { fileData: string, filename: Path, configString: string, - {instrument}: TransformOptions, + {instrument, rootDir}: CacheKeyOptions, ): string { return crypto .createHash('md5') @@ -90,7 +90,7 @@ const createTransformer = (options: any) => { .update('\0', 'utf8') .update(fileData) .update('\0', 'utf8') - .update(filename) + .update(path.relative(rootDir, filename)) .update('\0', 'utf8') .update(configString) .update('\0', 'utf8') diff --git a/packages/jest-runtime/src/script_transformer.js b/packages/jest-runtime/src/script_transformer.js index a459e7c6e10c..df25c07a1956 100644 --- a/packages/jest-runtime/src/script_transformer.js +++ b/packages/jest-runtime/src/script_transformer.js @@ -77,6 +77,7 @@ class ScriptTransformer { transformer.getCacheKey(fileData, filename, configString, { instrument, mapCoverage, + rootDir: this._config.rootDir, }), ) .update(CACHE_VERSION) diff --git a/types/Transform.js b/types/Transform.js index bdb04d1ae555..576720069956 100644 --- a/types/Transform.js +++ b/types/Transform.js @@ -28,6 +28,7 @@ export type TransformOptions = {| export type CacheKeyOptions = {| instrument: boolean, mapCoverage: boolean, + rootDir: string, |}; export type Transformer = {|