Skip to content

Commit cd2de18

Browse files
JoelTowellmeta-codesync[bot]
authored andcommitted
Add pnpm-lock.yaml to default lock files in autolinkLibrariesFromCommand (#58128)
Summary: Android autolinking caches the output of `npx react-native-community/cli config` so Gradle does not rerun it on every build. The cache is considered stale when certain files change, [currently only](https://github.com/react/react-native/blob/5b680c5f9fe5eae0f257939bd4a1fdbc543af419/packages/gradle-plugin/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsExtension.kt#L51-L54) `yarn.lock`, `package-lock.json`, `package.json`, and `react-native.config.js` by default. Notably, `pnpm-lock.yaml` is absent from that list, so a `pnpm install` that only touched the pnpm lockfile would keep using the old cache. Native libraries could be missing or stale until something else forced a refresh. This PR adds `pnpm-lock.yaml` to the default list in `autolinkLibrariesFromCommand`: ```kotlin .files( "yarn.lock", "package-lock.json", "package.json", "react-native.config.js", "pnpm-lock.yaml" ) ``` If a project already passes its own `lockFiles`, that override still wins, this only changes the default. It appears that SwiftPM iOS is already checking `pnpm-lock.yaml` to determine staleness [here](https://github.com/react/react-native/blob/5b680c5f9fe5eae0f257939bd4a1fdbc543af419/packages/react-native/scripts/spm/generate-spm-xcodeproj.js#L707-L732), so this change just brings Android in line with that. ## Changelog: [ANDROID] [FIXED] - Invalidate the Android autolinking cache when `pnpm-lock.yaml` changes Pull Request resolved: #58128 Test Plan: I didn't run `./gradlew test` as suggested [here](https://reactnative.dev/contributing/how-to-run-and-write-tests) because `settings.gradle.kts` in repo root [overrides](https://github.com/react/react-native/blob/5b680c5f9fe5eae0f257939bd4a1fdbc543af419/settings.gradle.kts#L41-L46) `lockFiles`, so RNTester would not hit the new default anyway. Ran the gradle-plugin unit tests: ``` yarn --cwd packages/gradle-plugin test ``` Output: ``` $ ./gradlew check BUILD SUCCESSFUL in 2m 11s 22 actionable tasks: 7 executed, 15 up-to-date Consider enabling configuration cache to speed up this build: https://docs.gradle.org/9.4.1/userguide/configuration_cache_enabling.html ✨ Done in 131.90s. ``` Reviewed By: christophpurrer Differential Revision: D122802857 Pulled By: cortinico fbshipit-source-id: 5df649c5eb01493743e430d63eb0e747619a86cd
1 parent df85975 commit cd2de18

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎packages/gradle-plugin/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsExtension.kt‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ abstract class ReactSettingsExtension @Inject constructor(val settings: Settings
5151
lockFiles: FileCollection =
5252
settings.layout.rootDirectory
5353
.dir("../")
54-
.files("yarn.lock", "package-lock.json", "package.json", "react-native.config.js"),
54+
.files(
55+
"yarn.lock",
56+
"package-lock.json",
57+
"package.json",
58+
"react-native.config.js",
59+
"pnpm-lock.yaml",
60+
),
5561
) {
5662
outputFile.parentFile.mkdirs()
5763

0 commit comments

Comments
 (0)