Skip to content

Commit 4d7ddd4

Browse files
iBotPeachesfacebook-github-bot
authored andcommitted
build: allow packager override for PROJECT_ROOT (#35354)
Summary: This allows folks with a monorepo setup for React Native to set a simple configuration on the "Bundle React Native code and images" phase. This is because the bundler was configured to look for node_modules in a specific place, but in a monorepo your node_modules may be at the root one layer lower than a default configuration. This same pattern of overriding this variable exists in the [react-native-xcode](https://github.com/facebook/react-native/blob/main/scripts/react-native-xcode.sh#L63) file. Fixes: #33636 - "Unable to resolve module index" ``` Error: Unable to resolve module ./index from /Volumes/Nexus/Projects/xxx/.: None of these files exist: * index(.native|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx) * index/index(.native|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx) ``` ## Changelog [General] [Added] - Add support for overriding `PROJECT_ROOT` during bundle steps for monorepos. Pull Request resolved: #35354 Test Plan: Working CI build via CircleCI. Reviewed By: cipolleschi Differential Revision: D41319439 Pulled By: ryancat fbshipit-source-id: 8516e54436b0a9d4b9df1efeee8e62c95d4d35b2
1 parent e047eed commit 4d7ddd4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

scripts/packager.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
99
REACT_NATIVE_ROOT="$THIS_DIR/.."
1010
# Application root directory - General use case: react-native is a dependency
11-
PROJECT_ROOT="$THIS_DIR/../../.."
11+
PROJECT_ROOT=${PROJECT_ROOT:-"$THIS_DIR/../../.."}
1212

1313
# check and assign NODE_BINARY env
1414
# shellcheck disable=SC1090
1515
source "${THIS_DIR}/node-binary.sh"
1616

1717
# When running react-native tests, react-native doesn't live in node_modules but in the PROJECT_ROOT
18-
if [ ! -d "$PROJECT_ROOT/node_modules/react-native" ];
18+
if [ ! -d "$THIS_DIR/../../../node_modules/react-native" ];
1919
then
2020
PROJECT_ROOT="$THIS_DIR/.."
2121
fi

0 commit comments

Comments
 (0)