-
Notifications
You must be signed in to change notification settings - Fork 653
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
Can we load multiple hermes' bundles in a single VM? #98
Comments
Yes, Hermes is designed to load multiple bundles in one VM instance. |
@tmikov Does this mean we can share JS context between bundles?, |
Yes. You can think about it like this: loading a bytecode bundle into an instance of the Hermes VM is exactly the same as loading a source file (for example by performing an eval() on it) in other VMs. In JSI it is done using Runtime::evaluateJavaScript(), which can accept either a pre-compiled bytecode bundle or a source file. The second part of your question is whether you can reference modules from the other bundle. That depends on what packager you used, and is basically not up to Hermes. |
But with metro-bundler there's no way to generate bundled chunks, do you think we can use other bundlers like webpack and then transform the bundle-chunks with hermes-cli ? |
Most likely. Hermes is agnostic to the bundler. Our compilation process doesn't change the semantic of the code, so if the bundler provides the functionality you need and depends only on standard JS features, it should just work with Hermes. For example if it works when you load the separate chunks as source in JSC, it should similarly work in Hermes if you compile them separately and load them as bytecode. |
Thanks @tmikov, Will try this. |
Hi, I tried loading multiple bundles and I got this crash
The first bundle was my application and it got loaded properly, the second bundle was just a file with console log test.js Bundle Commands
|
It seems that he problem you are describing is not in Hermes but in integrating multiple bundles with ReactNative, which is a bit out of my expertise. Hermes can load multiple bundles, but how to do that in ReactNative is a different question. Was this working with JSC? |
Yes, this was working with JSC, I think the problem is in optimizer, optimizer generates the bundle where all the allocations like(strings, functions) are put in a table, I'm guessing that a bundle can access the table of another bundle. Can this be the case? |
@RajeshBatth there is no semantic difference between loading source code and loading a bytecode bundle, except the latter is faster. The error you described isn't coming from Hermes, it happens before Hermes has even been invoked, as you can see here: Looking at the code, to get that error either the asset manager is missing, or it can't access the file. |
@RajeshBatth Hey, did you find a way to solve that problem? I'm trying to load base bundle containing common features, and other bundles containing just logic code. |
@nthtrung09it my suggestion is to ask for help in React Native, since it isn't caused by Hermes per se. |
@nthtrung09it Yes, I was able to load multiple bundles. It was pretty straightforward. |
- Disable Stats Timer (fixes facebook#92) - Include revision as part of product version in addition to suffix (fixes facebook#91) - Include license file in NuGet (fixes facebook#98) - Add Source Link to linker (fixes facebook#102) This is ported from the v0.11 branch. We bump the version up to 0.12 (even though no such version exists in upstream) to signal we're no longer compatible with 0.11 (and RN 0.68).
Include license metadata in NuGet (fixes facebook#98)
with RajeshBatth's answers, the key is loadSynchronously muse be set to false
|
I'm implementing my own code-push solution, where I want to load one base-bundle(vendor dependencies like RN) and multiple module-bundles(module can be a feature-set) on demand, with this I can fetch from server & update individual module-bundles.
The text was updated successfully, but these errors were encountered: