diff --git a/packages/metro-bundler/src/lib/GlobalTransformCache.js b/packages/metro-bundler/src/lib/GlobalTransformCache.js index 31d27cef..c0a03e1c 100644 --- a/packages/metro-bundler/src/lib/GlobalTransformCache.js +++ b/packages/metro-bundler/src/lib/GlobalTransformCache.js @@ -99,10 +99,11 @@ class KeyResultStore { } /** - * The transform options contain absolute paths. This can contain, for - * example, the username if someone works their home directory (very likely). - * We need to get rid of this user-and-machine-dependent data for the global - * cache, otherwise nobody would share the same cache keys. + * The transform options contain absolute paths. This can contain, for example, + * the username if someone works their home directory (very likely). We get rid + * of this local data for the global cache, otherwise nobody would share the + * same cache keys. The project roots should not be needed as part of the cache + * key as they should not affect the transformation of a single particular file. */ function globalizeTransformOptions( options: TransformOptions, @@ -115,9 +116,7 @@ function globalizeTransformOptions( ...options, transform: { ...transform, - projectRoots: transform.projectRoots.map(p => { - return path.relative(path.join(__dirname, '../../../../..'), p); - }), + projectRoots: [], }, }; } diff --git a/packages/metro-bundler/src/lib/__tests__/GlobalTransformCache-test.js b/packages/metro-bundler/src/lib/__tests__/GlobalTransformCache-test.js index 1900ed85..17fee4a4 100644 --- a/packages/metro-bundler/src/lib/__tests__/GlobalTransformCache-test.js +++ b/packages/metro-bundler/src/lib/__tests__/GlobalTransformCache-test.js @@ -40,7 +40,7 @@ describe('GlobalTransformCache', () => { dev: true, minify: false, platform: 'ios', - transform: {projectRoots: [__dirname]}, + transform: {}, }; const result = await Promise.all([cache.fetch({ filePath: 'foo.js', 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 c0fdf1ad..70472f3a 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/2ad175cb80ae79fd33b914bfb392fb6742982d2a-foo.js */", + "code": "/* code from http://globalcache.com/17ce731dadd36402f15abb768843cb5e8ecf9ca7-foo.js */", "dependencies": Array [], "dependencyOffsets": Array [], }, Object { - "code": "/* code from http://globalcache.com/d6c0a1a4199d572ab68b36c07d0d68607eebb131-bar.js */", + "code": "/* code from http://globalcache.com/d78572916bd877b6ac0e819e99be9fc2954f0e00-bar.js */", "dependencies": Array [], "dependencyOffsets": Array [], },