From 1cae8d8007d04ba62a739a6c4dff991c69af26e4 Mon Sep 17 00:00:00 2001 From: Rob Hogan Date: Thu, 9 Jun 2022 15:16:30 -0700 Subject: [PATCH] Remove `unstable_hasteMapModulePath` from Metro config Summary: Remove the `unstable_hasteMapModulePath` config option from Metro and the corresponding `hasteMapModulePath` option from `metro-file-map`. We no longer need these internally and removing this indirection makes things easier to reason about, especially as this API effectively exposed internal behaviour in a way that could be broken unknowingly. Reviewed By: motiz88 Differential Revision: D36875896 fbshipit-source-id: 34214abadcc6fd56c6033ecb40452f59008b924f --- .../__snapshots__/loadConfig-test.js.snap | 4 ---- packages/metro-config/src/configTypes.flow.js | 1 - packages/metro-config/src/defaults/index.js | 1 - .../metro-config/src/defaults/validConfig.js | 1 - packages/metro-file-map/src/flow-types.js | 9 --------- packages/metro-file-map/src/index.js | 19 ------------------- .../DependencyGraph/createHasteMap.js | 1 - 7 files changed, 36 deletions(-) diff --git a/packages/metro-config/src/__tests__/__snapshots__/loadConfig-test.js.snap b/packages/metro-config/src/__tests__/__snapshots__/loadConfig-test.js.snap index 64695607a9..a5773cfe52 100644 --- a/packages/metro-config/src/__tests__/__snapshots__/loadConfig-test.js.snap +++ b/packages/metro-config/src/__tests__/__snapshots__/loadConfig-test.js.snap @@ -69,7 +69,6 @@ Object { "ts", "tsx", ], - "unstable_hasteMapModulePath": undefined, "useWatchman": true, }, "serializer": Object { @@ -215,7 +214,6 @@ Object { "ts", "tsx", ], - "unstable_hasteMapModulePath": undefined, "useWatchman": true, }, "serializer": Object { @@ -361,7 +359,6 @@ Object { "ts", "tsx", ], - "unstable_hasteMapModulePath": undefined, "useWatchman": true, }, "serializer": Object { @@ -507,7 +504,6 @@ Object { "ts", "tsx", ], - "unstable_hasteMapModulePath": undefined, "useWatchman": true, }, "serializer": Object { diff --git a/packages/metro-config/src/configTypes.flow.js b/packages/metro-config/src/configTypes.flow.js index 40c93aa69f..b9528ce22d 100644 --- a/packages/metro-config/src/configTypes.flow.js +++ b/packages/metro-config/src/configTypes.flow.js @@ -96,7 +96,6 @@ type ResolverConfigT = { emptyModulePath: string, extraNodeModules: {[name: string]: string, ...}, hasteImplModulePath: ?string, - unstable_hasteMapModulePath: ?string, nodeModulesPaths: $ReadOnlyArray, platforms: $ReadOnlyArray, resolveRequest: ?CustomResolver, diff --git a/packages/metro-config/src/defaults/index.js b/packages/metro-config/src/defaults/index.js index d5ef1b2405..55a0b95376 100644 --- a/packages/metro-config/src/defaults/index.js +++ b/packages/metro-config/src/defaults/index.js @@ -42,7 +42,6 @@ const getDefaultValues = (projectRoot: ?string): ConfigT => ({ ), extraNodeModules: {}, hasteImplModulePath: undefined, - unstable_hasteMapModulePath: undefined, nodeModulesPaths: [], resolveRequest: null, resolverMainFields: ['browser', 'main'], diff --git a/packages/metro-config/src/defaults/validConfig.js b/packages/metro-config/src/defaults/validConfig.js index a15f0aa413..d783961a4b 100644 --- a/packages/metro-config/src/defaults/validConfig.js +++ b/packages/metro-config/src/defaults/validConfig.js @@ -18,7 +18,6 @@ module.exports = (async () => { ...defaultConfig.resolver, resolveRequest: function CustomResolver() {}, hasteImplModulePath: './path', - unstable_hasteMapModulePath: './path', }, server: { ...defaultConfig.server, diff --git a/packages/metro-file-map/src/flow-types.js b/packages/metro-file-map/src/flow-types.js index eba41edcbe..1916cd80e4 100644 --- a/packages/metro-file-map/src/flow-types.js +++ b/packages/metro-file-map/src/flow-types.js @@ -83,15 +83,6 @@ export type HasteMap = { moduleMap: ModuleMap, }; -export type HasteMapStatic = { - getCacheFilePath( - cacheDirectory: string, - cacheFilePrefix: string, - buildParameters: BuildParameters, - ): string, - getModuleMapFromJSON(json: S): IModuleMap, -}; - export type HType = { ID: 0, MTIME: 1, diff --git a/packages/metro-file-map/src/index.js b/packages/metro-file-map/src/index.js index 84c5209726..9e8509a269 100644 --- a/packages/metro-file-map/src/index.js +++ b/packages/metro-file-map/src/index.js @@ -19,7 +19,6 @@ import type { FileData, FileMetaData, HasteMap as InternalDataObject, - HasteMapStatic, HType, InternalData, MockData, @@ -87,7 +86,6 @@ export type InputOptions = $ReadOnly<{ throwOnModuleCollision?: ?boolean, useWatchman?: ?boolean, watch?: ?boolean, - hasteMapModulePath?: ?string, console?: Console, cacheManagerFactory?: ?CacheManagerFactory, }>; @@ -230,24 +228,7 @@ export default class HasteMap extends EventEmitter { _worker: ?WorkerInterface; _cacheManager: CacheManager; - static getStatic( - config: $ReadOnly<{haste: $ReadOnly<{hasteMapModulePath?: string}>}>, - ): HasteMapStatic<> { - if (config.haste.hasteMapModulePath != null) { - // $FlowFixMe[unsupported-syntax] - Dynamic require - return require(config.haste.hasteMapModulePath); - } - // $FlowFixMe[prop-missing] - returning static class - // $FlowFixMe[method-unbinding] - returning static class - return HasteMap; - } - static create(options: InputOptions): HasteMap { - if (options.hasteMapModulePath != null) { - // $FlowFixMe[unsupported-syntax] - Dynamic require - const CustomHasteMap = require(options.hasteMapModulePath); - return new CustomHasteMap(options); - } return new HasteMap(options); } diff --git a/packages/metro/src/node-haste/DependencyGraph/createHasteMap.js b/packages/metro/src/node-haste/DependencyGraph/createHasteMap.js index 90fb1d3d7b..3b1fccdffb 100644 --- a/packages/metro/src/node-haste/DependencyGraph/createHasteMap.js +++ b/packages/metro/src/node-haste/DependencyGraph/createHasteMap.js @@ -72,7 +72,6 @@ function createHasteMap( extensions: config.resolver.sourceExts.concat(config.resolver.assetExts), forceNodeFilesystemAPI: !config.resolver.useWatchman, hasteImplModulePath: config.resolver.hasteImplModulePath, - hasteMapModulePath: config.resolver.unstable_hasteMapModulePath, ignorePattern: getIgnorePattern(config), maxWorkers: config.maxWorkers, mocksPattern: '',