cli icon indicating copy to clipboard operation
cli copied to clipboard

perf(autolinking)!: prioritise files with `*Package.java|*Package.kt` in `getPackageClassName`

Open szymonrybczak opened this issue 1 year ago • 0 comments

Summary:

This Pull Request changes schema that looks for files to check to find class name, after my tests in various application the match results were included almost in every library in files with Package at the end. But our previous logic was going through every file in library with .kt and .java extension until it found file with implements ReactPackage, some libraries can have 100+ files and we were reading them until we matched relevant Regex schema 😅

I also added a fallback which checks files with *.kt and *.java extensions if it couldn't find implements ReactPackage in file with *Package at the end, which ensures us that we don't introduce any breaking change. The output of config command stays the same.

Performance improvement

I did a test in Expensify app, which is an open-source app with 50 libraries containing native code. Before my changes, we were reading 490 files to find the class name. Right now, we only check 79 (still there's a room for improvements).

Before After
Files read 490 79
Time ~7.85s ~1.15s

Test Plan:

  1. Clone the repository and do all the required steps from the Contributing guide
  2. Run this command:
node /path/to/react-native-cli/packages/cli/build/bin.js config

The dependencies field should be the same as before.

Checklist

  • [x] Documentation is up to date to reflect these changes.
  • [x] Follows commit message convention described in CONTRIBUTING.md

szymonrybczak avatar May 08 '24 15:05 szymonrybczak