Skip to content

Commit

Permalink
fix: TVOSExample metro config
Browse files Browse the repository at this point in the history
  • Loading branch information
alduzy committed Oct 10, 2024
1 parent 323caf6 commit 7c80725
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions TVOSExample/metro.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');

/**
* Metro configuration
* https://reactnative.dev/docs/metro
*
* @type {import('metro-config').MetroConfig}
*/

const fs = require('fs');
const path = require('path');
const exclusionList = require('metro-config/src/defaults/exclusionList');
Expand All @@ -13,6 +20,7 @@ const rnsRoot = path.resolve(__dirname, '..');

const modules = [
'@react-navigation/native',
'@react-navigation/stack',
'react-native-reanimated',
'react-native-safe-area-context',
'react-native-gesture-handler',
Expand All @@ -30,7 +38,6 @@ const config = {
// We need to make sure that only one version is loaded for peerDependencies
// So we exclude them at the root, and alias them to the versions in example's node_modules
resolver: {
sourceExts: ['ts', 'tsx', 'js', 'jsx', 'json'],
blockList: exclusionList(
modules.map(
m =>
Expand All @@ -51,12 +58,6 @@ const config = {
// to various errors. To mitigate this we define below custom request resolver, hijacking requests to conflicting modules and manually
// resolving appropriate files. **Most likely** this can be achieved by proper usage of blockList but I found this method working ¯\_(ツ)_/¯
resolveRequest: (context, moduleName, platform) => {
if (moduleName.startsWith('@react-navigation')) {
// For some reason, react-navigation packages don't want to resolve from
// the project's node_modules, so we need to use standard Metro resolver.
return context.resolveRequest(context, moduleName, platform);
}

if (moduleName === 'react-native-screens') {
return {
filePath: path.join(rnsRoot, 'src', 'index.tsx'),
Expand Down

0 comments on commit 7c80725

Please sign in to comment.