diff --git a/packages/metro-bundler/src/lib/GlobalTransformCache.js b/packages/metro-bundler/src/lib/GlobalTransformCache.js index 1d2fe2c9..29585bee 100644 --- a/packages/metro-bundler/src/lib/GlobalTransformCache.js +++ b/packages/metro-bundler/src/lib/GlobalTransformCache.js @@ -232,9 +232,10 @@ class URIBasedGlobalTransformCache { hash.update(this._optionsHasher.getTransformWorkerOptionsDigest(transformOptions)); const cacheKey = props.getTransformCacheKey(transformOptions); hash.update(JSON.stringify(cacheKey)); + hash.update(JSON.stringify(localPath)); hash.update(crypto.createHash('sha1').update(sourceCode).digest('hex')); const digest = hash.digest('hex'); - return `${digest}-${localPath}`; + return `${digest}-${path.basename(localPath)}`; } /** diff --git a/packages/metro-bundler/src/lib/__tests__/__snapshots__/GlobalTransformCache-test.js.snap b/packages/metro-bundler/src/lib/__tests__/__snapshots__/GlobalTransformCache-test.js.snap index 9fadc646..88ce1547 100644 --- a/packages/metro-bundler/src/lib/__tests__/__snapshots__/GlobalTransformCache-test.js.snap +++ b/packages/metro-bundler/src/lib/__tests__/__snapshots__/GlobalTransformCache-test.js.snap @@ -19,12 +19,12 @@ Object { exports[`GlobalTransformCache fetches results 1`] = ` Array [ Object { - "code": "/* code from http://globalcache.com/cd6df9b7e86839dafc5e9b5b493a28cbc55074e7-some/where/foo.js */", + "code": "/* code from http://globalcache.com/b23da8c74218e6155fcaf590a0fedbd1d117c2ae-foo.js */", "dependencies": Array [], "dependencyOffsets": Array [], }, Object { - "code": "/* code from http://globalcache.com/6329a317fcf94d74cc9a1de6442ee7c25e27a507-some/where/else/bar.js */", + "code": "/* code from http://globalcache.com/5e95f6c3e9bac0282480cda6f1a984ad8bc83e55-bar.js */", "dependencies": Array [], "dependencyOffsets": Array [], },