Skip to content

Commit

Permalink
Expose unstable_fileMapCacheManagerFactory and use it internally
Browse files Browse the repository at this point in the history
Summary: Adds an `unstable_fileMapCacheManagerFactory` to config and passes it through to `metro-file-map`'s `cacheManagerFactory`

Reviewed By: motiz88

Differential Revision: D36697964

fbshipit-source-id: cf0ddcbbfd438d42c8c8dca208b05ef660db906e
  • Loading branch information
robhogan authored and facebook-github-bot committed Jun 6, 2022
1 parent d7dd9bf commit e741990
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions packages/metro-config/src/configTypes.flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import type {IncomingMessage, ServerResponse} from 'http';
import type {CacheStore} from 'metro-cache';
import typeof MetroCache from 'metro-cache';
import type {CacheManagerFactory} from 'metro-file-map';
import type {CustomResolver} from 'metro-resolver';
import type {MixedSourceMap} from 'metro-source-map';
import type {JsTransformerConfig} from 'metro-transform-worker';
Expand Down Expand Up @@ -118,6 +119,7 @@ type MetalConfigT = {
cacheVersion: string,
fileMapCacheDirectory?: string,
hasteMapCacheDirectory?: string, // Deprecated, alias of fileMapCacheDirectory
unstable_fileMapCacheManagerFactory?: CacheManagerFactory,
maxWorkers: number,
projectRoot: string,
stickyWorkers: boolean,
Expand Down
16 changes: 9 additions & 7 deletions packages/metro/src/node-haste/DependencyGraph/createHasteMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ function createHasteMap(
const computeDependencies = dependencyExtractor != null;

return MetroFileMap.create({
cacheManagerFactory: buildParameters =>
new DiskCacheManager({
buildParameters,
cacheDirectory:
config.fileMapCacheDirectory ?? config.hasteMapCacheDirectory,
cacheFilePrefix: options?.cacheFilePrefix,
}),
cacheManagerFactory:
config?.unstable_fileMapCacheManagerFactory ??
(buildParameters =>
new DiskCacheManager({
buildParameters,
cacheDirectory:
config.fileMapCacheDirectory ?? config.hasteMapCacheDirectory,
cacheFilePrefix: options?.cacheFilePrefix,
})),
computeDependencies,
computeSha1: true,
dependencyExtractor: config.resolver.dependencyExtractor,
Expand Down

0 comments on commit e741990

Please sign in to comment.