英文:
Significance of --indexed-ram-bundle for React Native bundling
问题
Recently I've started using RAM bundles with inline requires to achieve better performance for React Native startup. To do so I've pretty much just followed an official guide. It works fine, but in the Android part of the guide they say:
Use the following lines on Android if you want to use a single indexed file:
project.ext.react = [ bundleCommand: "ram-bundle", extraPackagerArgs: ["--indexed-ram-bundle"] ]
What is the significance of --indexed-ram-bundle
? Why would I want to, or not want to have a single indexed file?
I see that by default iOS appears to use a single indexed file, while Android will create a set of files.
英文:
Recently I've started using RAM bundles with inline requires to achieve better performance for React Native startup. To do so I've pretty much just followed an official guide. It works fine, but in the Android part of the guide they say:
> Use the following lines on Android if you want to use a single indexed file:
>
> project.ext.react = [
> bundleCommand: "ram-bundle",
> extraPackagerArgs: ["--indexed-ram-bundle"]
> ]
What is the significance of --indexed-ram-bundle
? Why would I want to, or not want to have a single indexed file?
I see that by default iOS appears to use a single indexed file, while Android will create a set of files.
答案1
得分: 1
"Indexed RAM bundle"(索引型RAM捆绑)格式将捆绑包组合成二进制文件...
这种结构在能够一次性加载所有代码到内存的环境下是最优的...
通常,这种捆绑方式用于iOS。
"File RAM bundle"(文件型RAM捆绑)每个模块都以文件的形式存储,名称为 js-modules/${id}.js
...
这种捆绑方式通常用于Android,因为包内容被压缩,访问压缩文件要快得多。如果使用索引格式,需要一次性解压所有捆绑内容才能获取相应模块的代码。
英文:
While unable to determine with great detail why one would like to do --indexed-ram-bundle
for Android the Metro documentation does provide some information:
>Indexed RAM bundle
>
>This format composes the bundle as a binary file
>...
>This structure is optimal for an environment that is able to load all code in memory at once
>...
>This bundling is usually used by iOS.
>
>File RAM bundle
>
>Each module is stored as a file, with the name js-modules/${id}.js
>...
>This bundling is usually used by Android, since package contents are zipped, and access to a zipped file is much faster. If the indexed format was used instead, all the bundled should be unzipped at once to get the code for the corresponding module.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论