You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As described by Ram in his article, Android can greatly benefit from using LazyReactPackage or TurboReactPackage to decrease startup time.
It requires adding annotations to native modules themselves but is also backwards compatible in the sense that if annotation is missing, the module still gets loaded, only not lazily.
From performance perspective, it's also better not to wrap every module in its own package - instead of nesting them, we can only have one package to wrap all native modules.
Possible Implementations
As part of the work on react-native config, we could update the MainApplication.java changes to include only one TurboReactPackage with all native modules in it.
Instead of adding a package per module we should add all native modules and view managers from each linked library to a single TurboReactPackage. We might need a way for libs to declare view manager and native modules classes. For native modules it could be possible to find them by checking for the @ReactModule annotation. For view managers this might be more complex since there is no annotation and we'd have to follow the inheritance chain to find if a class is a subclass of ViewManager.
There hasn't been any activity on this issue in the past 3 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.
Activity
janicduplessis commentedon Aug 3, 2019
Here's what the generated code should look like: https://gist.github.com/janicduplessis/6256d4bda0a59dd345654dacae106ea2.
Also this confirms that the approach of using a single
TurboReactPackageis right https://twitter.com/nparashuram/status/1157483387864489984.Instead of adding a package per module we should add all native modules and view managers from each linked library to a single
TurboReactPackage. We might need a way for libs to declare view manager and native modules classes. For native modules it could be possible to find them by checking for the@ReactModuleannotation. For view managers this might be more complex since there is no annotation and we'd have to follow the inheritance chain to find if a class is a subclass ofViewManager.sbearben commentedon Dec 29, 2019
@janicduplessis thank you for sharing that gist! From the twitter thread regarding using
ReactModuleSpecProcessor:Can you explain how you did this with gradle?
github-actions commentedon Dec 1, 2022
There hasn't been any activity on this issue in the past 3 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.