Repository navigation
feat(build): 去掉运行时用不到的包与语言资源 - #141
Merged
freedomkk-qfeng merged 5 commits intoOct 15, 2026
Merged
Conversation
Member
|
效果部分,增加下文件数量的对比 |
Contributor
Author
|
已在“效果”里补上两端的文件数对比和减少的构成。 |
JunieXD
marked this pull request as ready for review
October 12, 2026 03:24
This was referenced Oct 14, 2026
Member
Contributor
Author
|
已同步 main(8117a6a)。除回执外,还和 #143 在两处冲突,两边都保留了:
CI 全部通过。 与 #136 组合验证:在本地把 #136(ba65fd4)合进本分支,构建 macOS 包,并在 fork 上用开发构建工作流出 Windows 包(0.4.3-dev.20261014.10,CI 自带检查全部通过)。两端都用包内的 Node 和 Python 验证,Windows 在 Windows 11 虚拟机(x64 仿真)中运行:
组合后的体积(安装后大小按解压后的文件合计,文件数不含目录和符号链接;main 为 9b9803b):
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #119。第二阶段第一步:只去掉桌面产品不会加载的内容,不改功能。
改动
剔除用不到的包(
scripts/omit-runtime-packages.mjs):产品组装时去掉以下几类。@napi-rs/canvas;只被这些包依赖的包一并去掉;运行时 manifest 的根依赖和产品依赖始终保留。本次共去掉 73 个包,清单记在
assembly.json的omittedPackages中。Remotion 读取视频工程的 tsconfig 时会用到 TypeScript,因此保留。Remotion 打包器补丁(
scripts/patch-remotion-bundler-runtime.mjs):打包器一加载就引用 rspack 配置。补丁按 SHA-256 校验输入,改成用到 rspack 时才加载,记录在runtimePatches中。Electron 语言资源(
dsh-electron/scripts/electron-locales.mjs):两端只保留中文和英文,统计写入release.json的electronLocales。macOS 去掉
libpython3.12.dylib:解释器是静态链接的,扩展模块也不链接它。macOS 去掉内置 Node 的本地调试符号(
strip -x后重新 ad-hoc 签名):原生模块通过导出符号加载,不受影响;只是 Node 自身崩溃时,原生调用栈里看不到内部函数名。Windows 的node.exe本身不带符号。测试:剔除逻辑、补丁和语言资源都有单元测试。
validate-pinned-dsh-source在组装好的产品上检查三件事:剔除结果、Remotion 打包器能加载、文献检索能从 PDF 抽出文字。效果
与 main 9b9803b 对比。macOS arm64 为本机构建,用同一版本号;Windows 为开发构建工作流的 CI 产物。安装后的大小按解压后文件大小合计,文件数按解压后的文件计(不含目录和符号链接)。
文件数减少的构成:macOS 少 1,842 个,其中剔除的包 1,637 个、Electron 语言资源 204 个、
libpython3.12.dylib1 个;Windows 少 1,622 个,其中剔除的包 1,571 个、语言包 51 个。去掉的主要是体积较大的原生二进制,所以体积降了 11%–13%,文件数只少约 4%。去掉的包里有一部分源码映射和类型声明,#136 也会删,两个 PR 都合入后本 PR 的实际增量会小一些。
验证:macOS 27.0.1 arm64
codesign --verify --deep --strict也通过。DMG 挂载校验因本机受限环境拒绝hdiutil attach没有执行,main 对照包同样如此。node:sqlite;runtime-omissions测试,3 项全部通过。navigator.language由ja回落为en-US,Chromium 自带的菜单以及跟随浏览器语言的组件(侧栏 PDF、表格预览等)改为显示英文。这是只保留中英文的预期结果,中文和英文系统不受影响。验证:Windows
validate-pinned-dsh-source中,runtime-omissions测试在 macOS 和 Windows 上都通过。runtime-omissions测试,3 项通过;locales只剩中英文 4 个语言包。未测:原生 Windows x64 真机、带 tsconfig 的
video_project用户工程、完整的 a–k 功能清单。