Skip to content

perf: 优化打包大小 - #138

Merged
imsyy merged 1 commit into
SPlayer-Dev:devfrom
MoYingJi:pr/perf/size
Aug 7, 2026
Merged

imsyy merged 1 commit into
SPlayer-Dev:devfrom
MoYingJi:pr/perf/size

Conversation

@MoYingJi

@MoYingJi MoYingJi commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

改动类型

  • 新功能(feat)
  • 缺陷修复(fix)
  • 重构 / 优化(不改变对外行为)
  • 文档(docs)
  • 其他(请在「改动说明」中注明)

是否包含破坏性变更

  • 是(请在「改动说明」中详细描述)
  • 否

改动说明

  • 优化了 better-sqlite3 和 font-list 的体积(根据平台删除不会用到的东西)
  • 排除了部分依赖中的 TypeScript .ts 源代码文件

测试情况

resources 从 55.4 MiB 缩减至 38.7 MiB,且不影响正常功能

自查清单

  • 本 PR 只包含一个主要功能 / 修复,没有夹带无关改动
  • 已在本地完整测试通过;AI 生成的代码同样自行测试并审阅过,未做未经验证的提交
  • 已运行 pnpm format,并确认 pnpm typecheck、pnpm lint 通过
  • 改动涉及原生模块时已 pnpm build:native 验证;未手写 native/*/index.d.ts
  • 已向 dev 分支提交

@MoYingJi
MoYingJi marked this pull request as ready for review August 6, 2026 21:41
Copilot AI balanced review requested due to automatic review settings August 6, 2026 21:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Enables an afterPack hook to trim unused native module artifacts from the packaged Electron app, reducing output size.

Changes:

  • Turn on afterPack in electron-builder config.
  • Add post-pack trimming for better-sqlite3 and font-list platform/arch artifacts.
  • Adjust packaging exclude globs (e.g., exclude .ts, refine better-sqlite3 paths).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
scripts/after-pack.ts Adds afterPack hook logic to delete unused native binaries/libs per target platform/arch.
electron-builder.config.ts Enables afterPack hook and updates files exclusion patterns to reduce packaged content.

Comment thread scripts/after-pack.ts Resolved
Comment thread scripts/after-pack.ts Resolved
Comment thread scripts/after-pack.ts Resolved
Comment thread scripts/after-pack.ts Resolved
Copilot AI review requested due to automatic review settings August 6, 2026 22:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread scripts/after-pack.ts
}
};

const tryRm = async (path: string, options?: object): Promise<void> => {

@MoYingJi MoYingJi Aug 6, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

图片

坏了让我用到假的了

而且,你的建议才会让 pnpm prettier --check . 失败吧?还没达到换行的长度喔

Copilot AI review requested due to automatic review settings August 6, 2026 22:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (1)

scripts/after-pack.ts:15

  • 必修:这里把 options 声明为宽泛的 object,但 fs/promises.rm 要求 RmOptions;scripts/**/* 会被 tsconfig.node.json 检查,因此 pnpm typecheck/打包会在 rm(path, options) 处报类型不兼容。请直接从 rm 的签名推导参数类型。
const tryRm = async (path: string, options?: object): Promise<void> => {

@imsyy
imsyy merged commit 0900e25 into SPlayer-Dev:dev Aug 7, 2026
3 checks passed
@MoYingJi
MoYingJi deleted the pr/perf/size branch August 7, 2026 02:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants