From 6c581c9b9b67afe4c9ba39710d377e329e25e722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Thu, 21 Nov 2024 09:14:45 -0800 Subject: [PATCH] Allow JS_DIR path to be relative to cwd (#47877) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/47877 Changelog: [internal] Reviewed By: sammy-SC Differential Revision: D66302814 fbshipit-source-id: 55d6f86d098673e28fad71a43863f2041810d04b --- jest/integration/config/metro.config.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/jest/integration/config/metro.config.js b/jest/integration/config/metro.config.js index 3c8244156a5737..bff07bde93a524 100644 --- a/jest/integration/config/metro.config.js +++ b/jest/integration/config/metro.config.js @@ -17,6 +17,10 @@ const rnTesterConfig = getDefaultConfig( path.resolve('../../../packages/rn-tester'), ); +const JS_DIR = process.env.JS_DIR + ? path.resolve(process.cwd(), process.env.JS_DIR) + : null; + const config = { projectRoot: path.resolve(__dirname, '../../..'), reporter: { @@ -24,10 +28,10 @@ const config = { }, resolver: { blockList: /\/RendererProxy\.fb\.js$/, // Disable dependency injection for the renderer - disableHierarchicalLookup: !!process.env.JS_DIR, + disableHierarchicalLookup: !!JS_DIR, sourceExts: ['fb.js', ...rnTesterConfig.resolver.sourceExts], - nodeModulesPaths: process.env.JS_DIR - ? [path.join(process.env.JS_DIR, 'public', 'node_modules')] + nodeModulesPaths: JS_DIR + ? [path.join(JS_DIR, 'public', 'node_modules')] : [], hasteImplModulePath: path.resolve(__dirname, 'hasteImpl.js'), }, @@ -36,12 +40,12 @@ const config = { // using babel-register. babelTransformerPath: path.resolve(__dirname, 'metro-babel-transformer.js'), }, - watchFolders: process.env.JS_DIR + watchFolders: JS_DIR ? [ - path.join(process.env.JS_DIR, 'RKJSModules', 'vendor', 'react'), - path.join(process.env.JS_DIR, 'tools', 'metro'), - path.join(process.env.JS_DIR, 'node_modules'), - path.join(process.env.JS_DIR, 'public', 'node_modules'), + path.join(JS_DIR, 'RKJSModules', 'vendor', 'react'), + path.join(JS_DIR, 'tools', 'metro'), + path.join(JS_DIR, 'node_modules'), + path.join(JS_DIR, 'public', 'node_modules'), ] : [], };