Closed mjfusa closed 1 year ago
@acoates-ms You had some comments/thoughts on this in another thread, can you reflect that in here?
If this works on RN core we should identify what's needed to make it possible here (we're not intentionally blocking it in RNW).
Linking CodePush issue: #2477
I think the only thing really missing from RNW is the ability to tell an instance to load additional JS into an already running instance. -- The rest the app can build itself. In Office we use multiple bundles within an instance. -- But we provide those bundles at instance creation. So we will likely be exposing something here. But note that adding JS to the instance after instance creation has many more implications, that I dont think are very easily handled. (And I dont think the above article handles them either). For example the implementation in the above blog will not work with live reload, let alone fast refresh. -- You would severely affect your devX doing this.
@chrisglein I think we should reactivate this given other partners may need this Internal Task 29759475: Allow dynamically updating and loading a RNW bundle
For changing the bundle you should be able to point the instance uri to wherever your bundle is (where it comes from is up to the app). That should work.
Loading multiple bundles at a time is where the gap is. I hear that @vmoroz may be working on support for >1 bundle. Is that work tracked elsewhere? (should we use this issue, link to an existing issue, or create something new?)
You can load additional bundles using JSI
winrt::Microsoft::ReactNative::ExecuteJsi(reactContext, [wkThis](facebook::jsi::Runtime& runtime) {​​​​​​​​​​​
auto val = runtime.evaluateJavaScript(...);
}​​​​​​​​​
Note since this uses JSI, this is not compatible with webdebugging. But that is going away anyway.
@acoates-ms Can I close this issue? Is the solution you gave above sufficient or are there RNW changes still needed?
The runtime.evaluateJavaScript functionality provides all the necessary hooks to do this.
Since it looks like CodePush is not currently supporting RNW, is it possible in RNW to add a JS only component from an external source? Something like what they are doing here: Lazy Bundle Loading in React Native 🔥 - React Native Training - Medium. I need to modify the UI based on factors I won't know until first run of the app. The ideas is, I download the supporting components for the different scenarios I need to support.