Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions apps/common-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"@shopify/flash-list": "2.1.0",
"d3-shape": "3.2.0",
"fuse.js": "patch:fuse.js@npm%3A7.1.0#~/.yarn/patches/fuse.js-npm-7.1.0-5dcae892a6.patch",
"react": "19.1.1",
"react-dom": "19.1.1",
"react": "19.2.0",
"react-dom": "19.2.0",
"react-native-gesture-handler": "2.28.0",
"react-native-mmkv": "4.0.0",
"react-native-nitro-modules": "0.31.9",
Expand All @@ -52,21 +52,21 @@
"@react-native-community/cli": "20.0.0",
"@react-native-community/cli-platform-android": "20.0.0",
"@react-native-community/cli-platform-ios": "20.0.0",
"@react-native/babel-preset": "0.82.0",
"@react-native/eslint-config": "0.82.0",
"@react-native/metro-config": "0.82.0",
"@react-native/typescript-config": "0.82.0",
"@react-native/babel-preset": "0.83.0-rc.4",
"@react-native/eslint-config": "0.83.0-rc.4",
"@react-native/metro-config": "0.83.0-rc.4",
"@react-native/typescript-config": "0.83.0-rc.4",
"@tsconfig/react-native": "3.0.0",
"@types/d3-shape": "3.1.7",
"@types/jest": "30.0.0",
"@types/react": "19.2.2",
"@types/react": "19.2.0",
"@types/react-test-renderer": "19.1.0",
"eslint": "9.37.0",
"jest": "30.2.0",
"madge": "8.0.0",
"prettier": "3.6.2",
"react-native": "0.82.0",
"react-test-renderer": "19.1.1",
"react-native": "0.83.0-rc.4",
"react-test-renderer": "19.2.0",
"typescript": "5.8.3",
"typescript-eslint": "8.46.0"
}
Expand Down
56 changes: 49 additions & 7 deletions apps/common-app/scripts/dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,60 @@ const path = require('path');
/**
* @param {Object<string, string>} dependencies
* @param {Set<string>} exclude
* @param {((moduleName: string) => string) | undefined} localResolve
*/
function resolveDependencies(dependencies = {}, exclude) {
function resolveDependencies(dependencies = {}, exclude, localResolve) {
return Object.fromEntries(
Object.keys(dependencies)
.filter((name) => !exclude.has(name))
.map((name) => [
name,
{ root: path.resolve(__dirname, `../../../node_modules/${name}`) },
{
root: getRootPath(name, localResolve),
},
])
);
}

/**
* @param {string} moduleName
* @param {((moduleName: string) => string) | undefined} localResolve
*/
function getRootPath(moduleName, localResolve) {
let root;
if (localResolve) {
try {
root = path.dirname(localResolve(moduleName));
} catch {
// If a package defines an `exports` field, `require.resolve` can fail.
// Fortunately, none of the packages we care about cause this issue.
}
}
if (!root) {
try {
root = path.dirname(require.resolve(`${moduleName}/package.json`));
} catch {
// If a package defines an `exports` field, `require.resolve` can fail.
// Fortunately, none of the packages we care about cause this issue.
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this try ... catch block be repeated with the same comment? Maybe it'd better to add a helper function called e.g. tryResolve that will encapsulate this logic?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored in fd85705 (#8706)

return root;
}

/**
* This function will return the dependencies from the common-app package that
* aren't listed in the current app's package.json
*
* @param {string} currentAppDir - The current app directory (e.g. __dirname)
* @param {string[]} exclude - The dependencies to exclude from the common-app
* @param {string} [currentAppDir='.'] - The current app directory (e.g.
* __dirname). Default is `'.'`
* @param {string[]} [exclude=[]] - The dependencies to exclude from the
* common-app. Default is `[]`
* @param {(moduleName: string) => string} [localResolve] - Function that
* resolves a module name to its path from the app directory. This way modules
* resolved from the concrete app are prioritized before those from
* common-app.
*/
function getDependencies(currentAppDir = '.', exclude = []) {
function getDependencies(currentAppDir = '.', exclude = [], localResolve) {
const commonAppDir = path.resolve(__dirname, '..');
const commonAppPkg = require(path.resolve(commonAppDir, 'package.json'));

Expand All @@ -40,8 +74,16 @@ function getDependencies(currentAppDir = '.', exclude = []) {

return {
// Get all common-app dependencies that aren't already in the current app
...resolveDependencies(commonAppPkg.devDependencies, excludedDependencies),
...resolveDependencies(commonAppPkg.dependencies, excludedDependencies),
...resolveDependencies(
commonAppPkg.devDependencies,
excludedDependencies,
localResolve
),
...resolveDependencies(
commonAppPkg.dependencies,
excludedDependencies,
localResolve
),
};
}

Expand Down
8 changes: 4 additions & 4 deletions apps/fabric-example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ react {
// The root of your project, i.e. where "package.json" lives. Default is '../..'
// root = file("../../")
// The folder where the react-native NPM package is. Default is ../../node_modules/react-native
reactNativeDir = file("../../../../node_modules/react-native")
reactNativeDir = file("../../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
codegenDir = file("../../../../node_modules/@react-native/codegen")
codegenDir = file("../../node_modules/@react-native/codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js
cliFile = file("../../../../node_modules/react-native/cli.js")
cliFile = file("../../node_modules/react-native/cli.js")

/* Variants */
// The list of variants to that are debuggable. For those we're going to
Expand Down Expand Up @@ -45,7 +45,7 @@ react {

/* Hermes Commands */
// The hermes compiler command to run. By default it is 'hermesc'
hermesCommand = "../../node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc"
hermesCommand = "./node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc"
//
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
// hermesFlags = ["-O", "-output-source-map"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@
);
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "$(inherited)";
OTHER_CPLUSPLUSFLAGS = (
"$(OTHER_CFLAGS)",
"-DFOLLY_NO_CONFIG",
Expand All @@ -463,7 +464,7 @@
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../../../node_modules/react-native";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";
USE_HERMES = true;
Expand Down Expand Up @@ -538,6 +539,7 @@
"\"$(inherited)\"",
);
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_CFLAGS = "$(inherited)";
OTHER_CPLUSPLUSFLAGS = (
"$(OTHER_CFLAGS)",
"-DFOLLY_NO_CONFIG",
Expand All @@ -550,7 +552,7 @@
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../../../node_modules/react-native";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = true;
VALIDATE_PRODUCT = YES;
Expand Down
Loading
Loading