Skip to content

Commit

Permalink
add fallback to previous implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
tido64 committed Nov 1, 2024
1 parent 52c5c94 commit 01e7c20
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/react-native/react-native.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@
const verbose = process.env.DEBUG && process.env.DEBUG.includes('react-native');

function findCommunityPlatformPackage(spec, startDir = process.cwd()) {
// In a pnpm setup, we won't be able to find `@react-native-community/*`
// starting from the `react-native` directory. Instead, we must use the
// project's root.
const main = require.resolve(spec, { paths: [startDir] });
return require(main);
try {
// In monorepos, we cannot make any assumptions on where
// `@react-native-community/*` gets installed. The safest way to find it
// (barring adding an optional peer dependency) is to start from the project
// root, assuming the project root is the current working directory.
const main = require.resolve(spec, { paths: [startDir] });
return require(main);
} catch (_) {
return require(spec);
}
}

let android;
Expand Down

0 comments on commit 01e7c20

Please sign in to comment.