Skip to content

Commit c20963e

Browse files
RSNarafacebook-github-bot
authored andcommitted
Unregister JSDevSupport from DebugCorePackage
Summary: ## Problem `DebugCorePackage` is a `TurboReactPackage`. To register a `TurboReactPackage`s NativeModules, the `NativeModuleRegistryBuilder` loops over all `ReactModuleInfo`s in the package's auto-generated `ReactModuleInfo` list. This list is generated from the `ReactModuleList` annotation of the package using our annotation processors. Because `JSDevSupport` was in its package's `ReactModuleList` annotation, we generated a `ReactModuleInfo` object for it. Therefore, `NativeModuleRegistryBuilder` registered `JSDevSupport` twice (once in `DebugCorePackage` and twice in `Fb4aReactPackage`). ## How did this work before? `JSDevSupport` was always a part of the `ReactModuleList` annotation of `DebugCorePackage`. However, before D18974084 landed, there were two key things that made this work: 1. `DebugCorePackage` was a `LazyReactPackage`, 2. The `DebugCorePackage.getNativeModules()` did not return a `ModuleHolder` for `JSDevSupport`. For `LazyReactPackage`s, `NativeModuleRegistryBuilder` calls `LazyReactPackage.getNativeModuleIterator()` to register NativeModules. The iterator returned from `LazyReactPackage.getNativeModuleIterator()`, in this case, loops over the NativeModules returned from `DebugCorePackage.getNativeModules()`. Therefore, we don't register any NativeModules that aren't in `DebugCorePackage.getNativeModules()`. Since `DebugCorePackage.getNativeModules()` didn't contain `JSDevSupport`, it wasn't registered for the second time. Changelog: [Android][Fixed] - Unregister JSDevSupport from DebugCorePackage Reviewed By: ejanzer Differential Revision: D19187664 fbshipit-source-id: 34141c60542179567d75705937ba09ec8a3dfc2b
1 parent 5e9f4e6 commit c20963e

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

ReactAndroid/src/main/java/com/facebook/react/DebugCorePackage.java

-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
@ReactModuleList(
2828
nativeModules = {
2929
JSCHeapCapture.class,
30-
JSDevSupport.class,
3130
})
3231
public class DebugCorePackage extends TurboReactPackage {
3332
public DebugCorePackage() {}
@@ -37,8 +36,6 @@ public NativeModule getModule(String name, ReactApplicationContext reactContext)
3736
switch (name) {
3837
case JSCHeapCapture.TAG:
3938
return new JSCHeapCapture(reactContext);
40-
case JSDevSupport.MODULE_NAME:
41-
return new JSDevSupport(reactContext);
4239
default:
4340
throw new IllegalArgumentException(
4441
"In CoreModulesPackage, could not find Native module for " + name);

ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDevSupport.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import java.util.HashMap;
1818
import java.util.Map;
1919

20-
@ReactModule(name = JSDevSupport.MODULE_NAME, canOverrideExistingModule = true)
20+
@ReactModule(name = JSDevSupport.MODULE_NAME)
2121
public class JSDevSupport extends NativeJSDevSupportSpec {
2222
public static final String MODULE_NAME = "JSDevSupport";
2323

0 commit comments

Comments
 (0)