[v1.4] 压缩 ts.worker.js 至 4MB 以通过 AMO 验证,修复 MV3 background permission 错误#1221
Open
cyfung1031 wants to merge 28 commits intoscriptscat:release/v1.4from
Open
[v1.4] 压缩 ts.worker.js 至 4MB 以通过 AMO 验证,修复 MV3 background permission 错误#1221cyfung1031 wants to merge 28 commits intoscriptscat:release/v1.4from
cyfung1031 wants to merge 28 commits intoscriptscat:release/v1.4from
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
7ae0298 to
7bfacbb
Compare
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.
压缩 ts.worker.js 绕过 AMO 5MB 限制,修正 Firefox MV3 permission 错误
问题背景
Firefox MV3 扩充套件上架至 addons.mozilla.org (AMO) 时遭遇两个阻断性问题:
ts.worker.js超过 5MB 限制:Monaco Editor 的 TypeScript Worker 打包后约 5.9MB,超出 Mozilla 单档上限,导致 AMO 验证失败。worker-src blob::无法透过 Blob URL 动态建立 Worker,排除了原本的绕过方案。backgroundpermission 检查报错:Firefox MV3 不支援backgroundpermission,相关检查会抛出错误。解决方案
1. 新增
ZipExecutionPlugin(核心改动)在 Rspack 打包阶段新增自订插件
rspack-plugins/ZipExecutionPlugin.ts:ts.worker.js的 ASTeval或blob:压缩效果:5.9MB → ~3.8MB,低于 AMO 的 5MB 限制,且完全符合 Firefox MV3 的 CSP 规范。
2. 调整 Rspack 打包设定(
rspack.config.ts)ZipExecutionPlugin至打包流程3. Firefox 专用打包修正(
scripts/pack.js)data_collection_permissions字段(AMO 审核必要项目)backgroundpermission 的检查(Firefox MV3 不支援此 permission)4. UI 层移除 background permission 检查(
RuntimeSetting/index.tsx)backgroundpermission 的检查逻辑,避免在 Firefox 上报错修改档案一览
rspack-plugins/ZipExecutionPlugin.tsrspack.config.tsscripts/pack.jssrc/pages/components/RuntimeSetting/index.tsxbackgroundpermission UI 检查package.jsonacorn、magic-string依赖pnpm-lock.yaml测试结果
备注