Skip to content

[DRAFT] inject.js 瘦身#502

Closed
cyfung1031 wants to merge 15 commits intoscriptscat:mainfrom
cyfung1031:remove_trash_code
Closed

[DRAFT] inject.js 瘦身#502
cyfung1031 wants to merge 15 commits intoscriptscat:mainfrom
cyfung1031:remove_trash_code

Conversation

@cyfung1031
Copy link
Copy Markdown
Collaborator

@cyfung1031 cyfung1031 commented Jul 6, 2025

因為部份library (例如dayjs) 不是ES Modules
所以打包後體積過大

要把 types 從 ts實作 分離,而且 utils 中簡單工具也要分離,不依賴dayjs

Screenshot 2025-07-06 at 19 42 49

試作成果:418 KB (0.18.1) -> 142 KB ( 試作品 )

inject.js 及 content.js 都成功抽走垃圾代碼


(先等其他PR整合, 如 #494

#499 的 favicon.ts 會一併整合更新

@CodFrm
Copy link
Copy Markdown
Member

CodFrm commented Jul 6, 2025

确实应该将inject/content的utils工具方法和service_worker之类的方法分离开来,避免引用到不需要的内容,之前一直知道这个问题想做的

为什么把default都删除了,应该不影响吧

@cyfung1031
Copy link
Copy Markdown
Collaborator Author

确实应该将inject/content的utils工具方法和service_worker之类的方法分离开来,避免引用到不需要的内容,之前一直知道这个问题想做的

为什么把default都删除了,应该不影响吧

Screenshot 2025-07-06 at 21 39 20

比較方便看得出哪裡是真ESM吧。沒 { } 就是假模組
日後再改變也方便

不然會有 import ABC, { DEF } from ... 這些奇怪寫法吧

主要是整理 content.js 和 inject.js 那部份。 插件頁面(有React元件)的不管。

@cyfung1031
Copy link
Copy Markdown
Collaborator Author

@CodFrm 這個檔案有一堆TypeScript未定義的紅線,能幫助看一下嗎

https://github.com/scriptscat/scriptcat/blob/main/src/pages/components/CloudScriptPlan/index.tsx

另外,

ExportParams = ?
parseExportValue = ?
parseExportCookie = ?
CloudScriptFactory = ?


我看起來應該是不能编译 不知道為什麼一直以來能通過

@CodFrm
Copy link
Copy Markdown
Member

CodFrm commented Jul 7, 2025

@cyfung1031 重构mv3后,我都忘记这块了,这块很久没维护了,可能是我的eslint规则没那么严格,没有报错,处理了

@cyfung1031 cyfung1031 mentioned this pull request Jul 7, 2025
@cyfung1031
Copy link
Copy Markdown
Collaborator Author

移至 #505

@cyfung1031 cyfung1031 closed this Jul 7, 2025
@cyfung1031 cyfung1031 deleted the remove_trash_code branch July 8, 2025 14:41
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.

2 participants