Skip to content

Commit 2086bb6

Browse files
cpojerdratwas
authored andcommitted
feat: Only pass hasteImplModulePath if the hasteImpl file is available in RN (react-native-community#417)
1 parent 730b278 commit 2086bb6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/cli/src/tools/loadMetroConfig.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import path from 'path';
66
import {createBlacklist} from 'metro';
77
import {loadConfig} from 'metro-config';
8+
import {existsSync} from 'fs';
89
import {type ConfigT} from 'types';
910
import findSymlinkedModules from './findSymlinkedModules';
1011

@@ -31,13 +32,16 @@ const getBlacklistRE = () => createBlacklist([/.*\/__fixtures__\/.*/]);
3132
* Otherwise, a.native.js will not load on Windows or other platforms
3233
*/
3334
export const getDefaultConfig = (ctx: ConfigT) => {
35+
const hasteImplPath = path.join(ctx.reactNativePath, 'jest/hasteImpl');
3436
return {
3537
resolver: {
3638
resolverMainFields: ['react-native', 'browser', 'main'],
3739
blacklistRE: getBlacklistRE(),
3840
platforms: [...ctx.haste.platforms, 'native'],
3941
providesModuleNodeModules: ctx.haste.providesModuleNodeModules,
40-
hasteImplModulePath: path.join(ctx.reactNativePath, 'jest/hasteImpl'),
42+
hasteImplModulePath: existsSync(hasteImplPath)
43+
? hasteImplPath
44+
: undefined,
4145
},
4246
serializer: {
4347
getModulesRunBeforeMainModule: () => [

0 commit comments

Comments
 (0)