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.

先决条件

1 要求

Expo SDK 55 或更高版本
你的应用必须使用 Expo SDK 55 或更高版本。

启用包差异比较

🌐 Enable bundle diffing

打包包差异比较在两种情况下工作。默认情况下,已经运行已发布更新的设备在有新更新可用时会获取补丁。选择加入(实验性功能)后,新安装的设备也可以在第一次更新检查时获取补丁,而不是下载完整的新打包包。

🌐 Bundle diffing works in two situations. By default, devices already running a published update get a patch when a newer one is available. Opt in (experimental) and devices on a fresh install can also get a patch on their very first update check, instead of downloading the full new bundle.

更新之间的补丁

🌐 Patches between updates

在 SDK 56 及更高版本中默认启用。在 SDK 55 中,设置你项目的 应用配置 中的 updates.enableBsdiffPatchSupporttrue 以选择启用。

🌐 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.

app.json
{ "expo": { "updates": { "enableBsdiffPatchSupport": true } } }

要在 SDK 56 及更高版本中禁用,请将 enableBsdiffPatchSupport 设置为 false

🌐 To disable on SDK 56 and later, set enableBsdiffPatchSupport to false.

来自嵌入式打包包的补丁

🌐 Patches from the embedded bundle

信息 此模式是实验性的,需要用户选择启用。该标志和行为可能会发生变化。

要启用,请在 eas.json 的构建配置文件中,将 env 下的 EAS_UPDATE_EXPERIMENTAL_UPLOAD_EMBEDDED_BUNDLE 环境变量设置为:

🌐 To enable, set the EAS_UPDATE_EXPERIMENTAL_UPLOAD_EMBEDDED_BUNDLE environment variable under env in a build profile in eas.json:

eas.json
{ "build": { "production": { "env": { "EAS_UPDATE_EXPERIMENTAL_UPLOAD_EMBEDDED_BUNDLE": "1" } } } }

当构建完成时,EAS 会上传嵌入的包。随后发布到同一通道的更新可以作为针对它的补丁进行提供。如果你不使用 EAS Build,你可以自己上传嵌入的包。将 --bundle 指向 JavaScript 包,将 --manifest 指向本地构建生成的 app.manifest

🌐 When the build completes, EAS uploads the embedded bundle. Updates published later to the same channel can then be served as patches against it. 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:

Terminal
eas update:embedded:upload --platform [platform] --bundle [path] --manifest [path] --channel [name]

管理已上传的嵌入式包

🌐 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:

Terminal
eas update:embedded:list

查看单个嵌入包:

🌐 View a single embedded bundle:

Terminal
eas update:embedded:view [id]

删除嵌入的打包包:

🌐 Delete an embedded bundle:

Terminal
eas update:embedded:delete [id]

该命令可以安全地重试。

🌐 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

  • 全新安装将在首次更新时收到完整的打包包,除非你选择使用嵌入打包包的补丁
  • 补丁并不能保证立即适用于每一对可能的更新。 当发布更新时,EAS 更新只会针对该通道上倒数第二个更新预生成补丁。如果设备在运行不同的已发布更新时请求新的更新,它最初将接收到完整的包。随后,会根据需求为该特定基础更新生成补丁,并提供给将来的类似请求。
  • 补丁会在发布后不久生成。 从发布更新到补丁准备好可能需要几分钟。在此期间,设备可能会接收到完整的安装包。