From 114a913e6894bfe7d2499b6cf15264aba224ff30 Mon Sep 17 00:00:00 2001 From: cpojer Date: Wed, 5 Jun 2019 14:59:12 +0100 Subject: [PATCH] Only pass `hasteImplModulePath` if the `hasteImpl` file is available in RN. --- packages/cli/src/tools/loadMetroConfig.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/tools/loadMetroConfig.js b/packages/cli/src/tools/loadMetroConfig.js index 08497faa0..041586d41 100644 --- a/packages/cli/src/tools/loadMetroConfig.js +++ b/packages/cli/src/tools/loadMetroConfig.js @@ -5,6 +5,7 @@ import path from 'path'; import {createBlacklist} from 'metro'; import {loadConfig} from 'metro-config'; +import {existsSync} from 'fs'; import {type ConfigT} from 'types'; import findSymlinkedModules from './findSymlinkedModules'; @@ -31,13 +32,16 @@ const getBlacklistRE = () => createBlacklist([/.*\/__fixtures__\/.*/]); * Otherwise, a.native.js will not load on Windows or other platforms */ export const getDefaultConfig = (ctx: ConfigT) => { + const hasteImplPath = path.join(ctx.reactNativePath, 'jest/hasteImpl'); return { resolver: { resolverMainFields: ['react-native', 'browser', 'main'], blacklistRE: getBlacklistRE(), platforms: [...ctx.haste.platforms, 'native'], providesModuleNodeModules: ctx.haste.providesModuleNodeModules, - hasteImplModulePath: path.join(ctx.reactNativePath, 'jest/hasteImpl'), + hasteImplModulePath: existsSync(hasteImplPath) + ? hasteImplPath + : undefined, }, serializer: { getModulesRunBeforeMainModule: () => [