This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
EAS 更新的打包包差异比较
在可用时,使你的项目能够接受打包包差异。
通过打包包差异比较,EAS 更新在可能的情况下会提供打包包补丁。当你发布新更新时,EAS 更新可以生成一个更小的文件,其中仅包含设备上当前运行的打包包与新打包包之间的差异。这通常会显著减少更新下载大小。
🌐 With bundle diffing, EAS Update delivers a bundle patch when possible. When you publish a new update, EAS Update can generate a smaller file containing only the differences between the bundle currently running on the device and the new bundle. This often reduces update download size significantly.
启用包差异比较
🌐 Enable bundle diffing
打包包差异化在两种情况下有效。已经运行已发布更新的设备在有新更新可用时会收到补丁。全新安装的设备在第一次检查更新时也可以收到补丁,而不是下载完整的新打包包,这需要上传构建时嵌入的打包包。第一种情况在 SDK 56 及以后版本默认启用,第二种情况在 SDK 58 及以后版本默认启用。
🌐 Bundle diffing works in two situations. Devices already running a published update get a patch when a newer one is available. Devices on a fresh install can also get a patch on their very first update check, instead of downloading the full new bundle, when the embedded bundle from the build has been uploaded. The first is enabled by default in SDK 56 and later, and the second in SDK 58 and later.
更新之间的补丁
🌐 Patches between updates
在 SDK 56 及更高版本中默认启用。在 SDK 55 中,设置你项目的 应用配置 中的 updates.enableBsdiffPatchSupport 为 true 以选择启用。
🌐 Enabled by default in SDK 56 and later. On SDK 55, set updates.enableBsdiffPatchSupport to true in your project's app config to opt in.
要在 SDK 56 及更高版本中禁用,请将 enableBsdiffPatchSupport 设置为 false。
🌐 To disable on SDK 56 and later, set enableBsdiffPatchSupport to false.
来自嵌入式打包包的补丁
🌐 Patches from the embedded bundle
EAS Build 在构建完成后会上传嵌入的包。之后发布到同一通道的更新就可以作为补丁来提供了。无需任何配置。
🌐 EAS Build uploads the embedded bundle when the build completes. Updates published later to the same channel can then be served as patches against it. No configuration is required.
要禁用上传,请在 eas.json 的构建配置文件中的 env 下,将环境变量 EAS_UPDATE_UPLOAD_EMBEDDED_BUNDLE 设置为 0:
🌐 To disable the upload, set the EAS_UPDATE_UPLOAD_EMBEDDED_BUNDLE environment variable to 0 under env in a build profile in eas.json:
信息 在 SDK 57 及以下版本中,此模式是实验性的,需要选择加入。相关标志和行为可能会发生变化。
要启用,在 eas.json 的构建配置文件里,将 env 下的 EAS_UPDATE_EXPERIMENTAL_UPLOAD_EMBEDDED_BUNDLE 环境变量设置为 1:
🌐 To enable, set the EAS_UPDATE_EXPERIMENTAL_UPLOAD_EMBEDDED_BUNDLE environment variable to 1 under env in a build profile in eas.json:
当构建完成后,EAS Build 会上传嵌入的包。之后发布到同一个通道的更新可以作为补丁来使用。
🌐 When the build completes, EAS Build uploads the embedded bundle. Updates published later to the same channel can then be served as patches against it.
自定义构建 使用 eas/build 上传嵌入的包的方式也是一样的。如果你的自定义构建配置使用的是单独步骤,那么添加 eas/upload_embedded_bundle 步骤。
只有在你的项目中配置了 EAS Update 并且构建配置文件设置了 channel 时,EAS Build 才会上传 bundle。它会跳过开发构建和 iOS 模拟器构建的上传。要确认上传情况,请查找带有 eas update:embedded:list 的 bundle。
🌐 EAS Build uploads the bundle only when EAS Update is configured in your project and the build profile sets a channel. It skips the upload for development builds and iOS Simulator builds. To confirm the upload, look for the bundle with eas update:embedded:list.
如果你不使用 EAS Build,你可以自己上传嵌入的包。将 --bundle 指向 JavaScript 包,--manifest 指向原生构建生成的 app.manifest:
🌐 If you don't use EAS Build, you can upload an embedded bundle yourself. Point --bundle at the JavaScript bundle and --manifest at the app.manifest produced by the native build:
管理已上传的嵌入式包
🌐 Manage uploaded embedded bundles
找到包含 eas update:embedded:list 的 ID,然后将它们传递给查看或删除。
🌐 Find ids with eas update:embedded:list, then pass them to view or delete.
列出为你的项目注册的嵌入式包:
🌐 List the embedded bundles registered for your project:
查看单个嵌入包:
🌐 View a single embedded bundle:
删除嵌入的打包包:
🌐 Delete an embedded bundle:
该命令可以安全地重试。
🌐 The command is safe to retry.
验证包差异是否正在提供
🌐 Verify bundle diffs are being served
Expo 网站
🌐 Expo website
你可以在 更新详情 页面确认打包包差异是否已提供。打开你发布的更新组,然后选择你想要检查的平台。
🌐 You can confirm that bundle diffs are being served from the Update Details page. Open the Update Group you published, then select the platform you want to inspect.
更新 API
🌐 Updates API
你可以通过使用 Updates.readLogEntriesAsync() 检查更新日志来确认是否提供了 bundle 差异。如果你的应用收到了补丁,你将看到一条条目,显示补丁已成功应用(例如,“补丁成功应用”)。
🌐 You can confirm that bundle diffs are being served by inspecting update logs with Updates.readLogEntriesAsync(). If your app received a patch, you will see an entry indicating it was successfully applied (for example, "patch successfully applied").
补丁生成与发布
🌐 Patch generation and serving
EAS 更新使用 bsdiff 算法 来生成包补丁。
🌐 EAS Update uses the bsdiff algorithm to generate bundle patches.
补丁仅在以下情况下提供:
🌐 A patch is served only when:
- 它比完整包显著更小。 如果不是,EAS Update 会改为提供完整包。
- 它可以高效地计算。 如果生成补丁耗费的资源过多,EAS 更新会改为提供完整的包。
当前限制
🌐 Current limitations
- 全新安装在第一次更新时会收到完整的包,除非构建中嵌入的包已被上传。从 SDK 58 及更高版本开始默认如此。详见 嵌入包的补丁。
- 补丁并不能保证立即适用于每一对可能的更新。 当发布更新时,EAS 更新只会针对该通道上倒数第二个更新预生成补丁。如果设备在运行不同的已发布更新时请求新的更新,它最初将接收到完整的包。随后,会根据需求为该特定基础更新生成补丁,并提供给将来的类似请求。
- 补丁会在发布后不久生成。 从发布更新到补丁准备好可能需要几分钟。在此期间,设备可能会接收到完整的安装包。