--indexed-ram-bundle 对于 React Native 捆绑的意义

Significance of --indexed-ram-bundle for React Native bundling

最近我开始使用带有内联需求的 RAM 包来实现更好的 React Native 启动性能。为此,我几乎 followed an official guide。它工作正常,但在指南的 Android 部分他们说:

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"]
]

--indexed-ram-bundle有什么意义?为什么我想要或不想拥有一个索引文件?

我看到默认情况下 iOS 似乎使用单个索引文件,而 Android 将创建一组文件。

虽然无法非常详细地确定为什么要为 Android 做 --indexed-ram-bundle the Metro documentation 确实提供了一些信息:

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.