cli icon indicating copy to clipboard operation
cli copied to clipboard

Support lazy/turbo packages

Open lithin opened this issue 6 years ago • 3 comments

Describe the Feature

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.

lithin avatar Apr 25 '19 08:04 lithin

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 TurboReactPackage is 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 @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.

janicduplessis avatar Aug 03 '19 03:08 janicduplessis

@janicduplessis thank you for sharing that gist! From the twitter thread regarding using ReactModuleSpecProcessor:

Actually it looks super easy to do, just need to tell the java compiler where the annotation processor is

Can you explain how you did this with gradle?

sbearben avatar Dec 29 '19 00:12 sbearben

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.

github-actions[bot] avatar Dec 01 '22 03:12 github-actions[bot]