-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chore: migrate repack native modules to turbo modules #344
Conversation
|
4ed60f4
to
742f9fb
Compare
packages/repack/android/src/newarch/java/com/callstack/repack/ChunkManagerModule.kt
Show resolved
Hide resolved
|
||
} | ||
|
||
fun loadScript(scriptId: String, configMap: ReadableMap, promise: Promise, remoteLoader: RemoteScriptLoader, fileSystemLoader: FileSystemScriptLoader) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit]: as an improvement, we can consider rewriting it to follow the bob pattern:
https://github.com/callstack/react-native-builder-bob/tree/main/packages/create-react-native-library/templates/java-library-mixed/android/src
cc @thymikee
packages/repack/android/src/newarch/java/com/callstack/repack/ChunkManagerModule.kt
Outdated
Show resolved
Hide resolved
packages/repack/android/src/main/java/com/callstack/repack/ChunkManagerPackage.kt
Outdated
Show resolved
Hide resolved
…-repack-to-turbo-modules
…llstack/repack into chore/migrate-repack-to-turbo-modules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have much experience when it comes to New Architecture so if @troZee says it's looking good from the configuration perspective I trust his judgment :)
However, one thing that I don't like is that the native implementation of the prefetchScript
, loadScript
, and invalidateScripts
methods is duplicated, thus making the maintenance cost higher in the future. Is this expected when writing backward-compatible modules? That would be a weird design TBH.
ScriptManagerModuleImpl.NAME, // name | ||
ScriptManagerModuleImpl.NAME, // className | ||
false, // canOverrideExistingModule | ||
false, // needsEagerInit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what exactly needsEagerInit
means, but I'd say Repack should be initialized & available as soon as possible, especially in the Module Federation architecture we're now treating as a recommended one.
Take a look at the Super App Showcase Host App – https://github.com/callstack/super-app-showcase/blob/main/packages/host/index.js ScriptManager is used before the App component is registered.
Of course, what I'm saying here might be completely wrong since I'm not that familiar with the New Arch – if that's the case, sorry for the confusion :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On repack side, i'm not sure how eager it needs to be initialised (even though i feel it's still initialised and available), however this is the default spec from docs and i'm sure it can be set to Eagerly initialise.
Yes, that's the implementation for backward compatibility. There's a common module with the actual implementation of |
This pull request has been marked as stale because it has been inactive for 60 days. Please update this pull request or it will be automatically closed in 14 days. |
Hi, any ETA on this improvement? Thanks! |
Closing in favour of #495 |
Thank you @teneeto for your all work on this PR 🙏 |
Summary
This PR aims to enable newArch and make
re.pack
native modules toturbo modules
while ensuring newArch is implemented with backward compatibility.re.pack
current implementation directly uses RN native modules, but with this change, there is aSPEC
implementation that allows for more efficient communication between native and JavaScript. This change allows for both old and new architecture.Test plan
RN>=0.68.0
NOTE: TesterApp currently meets this requirement if you're using repack TesterApp.
For Android
You will only need to update your
android/gradle.properties
file as follows:newArchEnabled=true
and then
yarn TesterApp:start
For iOS
Run pod install with the flags:
RCT_NEW_ARCH_ENABLED=1 pod install
and then
yarn TesterApp:start
Screen Records
Screen.Recording.2023-04-17.at.13.00.01.mov
Screen.Recording.2023-04-17.at.13.13.11.mov
Screen.Recording.2023-04-17.at.13.39.30.mov
Screen.Recording.2023-04-17.at.13.26.39.mov