Skip to content

Commit 46d17ef

Browse files
dmytrorykunfacebook-github-bot
authored andcommitted
Start looking for codegen-enabled dependencies from the project root (#46229)
Summary: Pull Request resolved: #46229 When running codegen from `pod install`, something affects `require.resolve`, and it starts looking for codegen-enabled dependencies from the workspace root, not the current RN project root. This is bad if we have different versions of same dependency across multiple workspaces. One of them will be hoisted to the workspace root, and will be used for all the workspaces. This issue is described in details here #46196 This diff is supposed to fix this by adding the project root path to the `require.resolve` call. Changelog: [iOS][Fixed] - Codegen will start looking for codegen-enabled dependencies from the project root. Reviewed By: cipolleschi Differential Revision: D61850219 fbshipit-source-id: d60a0e72e9c60e862c0d64e227ea3652d1be5a90
1 parent 773fc8d commit 46d17ef

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/react-native/scripts/codegen/generate-artifacts-executor.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ function extractSupportedApplePlatforms(dependency, dependencyPath) {
225225
return supportedPlatformsMap;
226226
}
227227

228-
function findExternalLibraries(pkgJson) {
228+
function findExternalLibraries(pkgJson, projectRoot) {
229229
const dependencies = {
230230
...pkgJson.dependencies,
231231
...pkgJson.devDependencies,
@@ -240,6 +240,7 @@ function findExternalLibraries(pkgJson) {
240240
try {
241241
const configFilePath = require.resolve(
242242
path.join(dependency, 'package.json'),
243+
{paths: [projectRoot]},
243244
);
244245
const configFile = JSON.parse(fs.readFileSync(configFilePath));
245246
const codegenConfigFileDir = path.dirname(configFilePath);
@@ -533,7 +534,7 @@ function findCodegenEnabledLibraries(pkgJson, projectRoot) {
533534
} else {
534535
return [
535536
...projectLibraries,
536-
...findExternalLibraries(pkgJson),
537+
...findExternalLibraries(pkgJson, projectRoot),
537538
...findLibrariesFromReactNativeConfig(projectRoot),
538539
];
539540
}

0 commit comments

Comments
 (0)