Repository navigation
Let Android release bundles skip --reset-cache - #59547
Conversation
|
The build_android failure isn't from this change. It also fails on main since the Kotlin 2.3.21 update (#59535): |
|
/rebase |
| * Whether to pass `--reset-cache` to the [bundleCommand]. Disable it to keep the Metro cache | ||
| * between release builds. Default: true | ||
| */ | ||
| val resetCache: Property<Boolean> = objects.property(Boolean::class.java).convention(true) |
There was a problem hiding this comment.
Name is too generic. resetCache can mean a bunch of things for react native. This should be more specific
c4fb600 to
00b4873
Compare
|
Renamed it to |
I think this should be called something like I would also suggest that we don't create a new entry in the ReactExtension but instead use a gradle property like |
|
I dropped the |
| * Public property that controls whether `--reset-cache` is passed to Metro when bundling the JS | ||
| * for release builds. Default: true | ||
| */ | ||
| const val RESET_METRO_CACHE_BEFORE_BUNDLING = "react.resetMetroCacheBeforeBundling" |
There was a problem hiding this comment.
This should follow the convention in this file. You sould accept both a SCOPED_ version of this property with react.resetMetroCacheBeforeBundling and an unscoped one with resetMetroCacheBeforeBundling
There was a problem hiding this comment.
Done in c50219c. It now reads both react.resetMetroCacheBeforeBundling and resetMetroCacheBeforeBundling. If both are set, the scoped one wins, same as includeJitpackRepository.
|
@cortinico has imported this pull request. If you are a Meta employee, you can view this in D128660659. |
Summary:
BundleHermesCTaskalways passes--reset-cacheto the bundle command, and there is no way to turn it off. Metro's default cache lives inos.tmpdir()/metro-cache, which every Metro on the machine shares. So each Android release bundle wipes the cache of other projects and dev servers, and on Windows it can fail withENOTEMPTYwhen another Metro writes into that folder during the reset.This adds a
react.resetMetroCacheBeforeBundlingGradle property, withresetMetroCacheBeforeBundlingas the unscoped name. It defaults totrue, so builds work as before. Setreact.resetMetroCacheBeforeBundling=falseingradle.propertiesto drop the flag from the bundle command. If both names are set, the scoped one wins, as withreact.includeJitpackRepository.Fixes #59543
Changelog:
[ANDROID] [ADDED] - Add
react.resetMetroCacheBeforeBundling(orresetMetroCacheBeforeBundling) Gradle property to let release bundles keep the Metro cacheTest Plan:
Added
ProjectUtilsTestcases for both property names (default,true,false, invalid value, and both set) andgetBundleCommand_withResetMetroCacheBeforeBundlingDisabled_returnsCommandWithoutResetCachetoBundleHermesCTaskTest. The existing command tests still expect--reset-cacheby default../gradlew :react-native-gradle-plugin:testpasses for both classes, and ktfmt is clean on the changed files.