Files
react-native/jest/integration/config/metro.config.js
Rubén NorteandFacebook GitHub Bot 6c581c9b9b 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
2024-11-21 09:14:45 -08:00

54 lines
1.5 KiB
JavaScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
'use strict';
const {getDefaultConfig} = require('@react-native/metro-config');
const {mergeConfig} = require('metro-config');
const path = require('path');
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: {
update: () => {},
},
resolver: {
blockList: /\/RendererProxy\.fb\.js$/, // Disable dependency injection for the renderer
disableHierarchicalLookup: !!JS_DIR,
sourceExts: ['fb.js', ...rnTesterConfig.resolver.sourceExts],
nodeModulesPaths: JS_DIR
? [path.join(JS_DIR, 'public', 'node_modules')]
: [],
hasteImplModulePath: path.resolve(__dirname, 'hasteImpl.js'),
},
transformer: {
// We need to wrap the default transformer so we can run it from source
// using babel-register.
babelTransformerPath: path.resolve(__dirname, 'metro-babel-transformer.js'),
},
watchFolders: JS_DIR
? [
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'),
]
: [],
};
module.exports = mergeConfig(rnTesterConfig, config);