
众所周知,electron 的程序体积非常大
一个 helloworld 都将近 160MB 了
然后我就想有没有什么解决方法
毕竟如果没有二进制依赖的话 electron 其实是只生成一个 app.asar 的?(可能还要 app-update.yml 什么的)
然后我想有没有可能把 electron 应用的 app.asar 都独立出来,然后使用 electron app.asar 这样的命令来启动应用
这时候只需要一个启动器,用来检查是否安装了 electron,然后检查更新什么的,并用 electron 启动 app.asar 不就行了?
这样的话多个应用也能减少体积(毕竟只有一个 electron 本体了)
如果是直接打包的网页版本,那就更直接了,直接 electron https://v2ex.com/ 这样子的命令就可以
毕竟 electron 也写了: To run a local app, execute the following on the command line: electron path-to-app
各位大佬看看,可行性高吗?
附上 electron 的 help:
Electron 9.2.1 - Build cross platform desktop apps with Javascript, HTML, and CSS Usage: electron [options] [path] A path to an Electron app may be specified. It must be one of the following: - index.js file. - Folder containing a package.json file. - Folder containing an index.js file. - .html/.htm file. - http://, https://, or file:// URL. Options: -i, --interactive Open a REPL to the main process. -r, --require Module to preload (option can be repeated). -v, --version Print the version. -a, --abi Print the Node ABI version. 1 love 2020-08-19 21:30:57 +08:00 你这样不是要先安装一个 electron ?那为何不直接用平台原生浏览器核心,都省了这一步了 |
2 Cbdy 2020-08-19 21:34:19 +08:00 via Android 您说的是 pwa 吧 |
3 timpaik OP @love windows 的 webview 是 edge 或者 IE,那玩意完全没法用吧 新 edge 目前没有预装?并且我装了新 edge,webview 还是旧 edge |
5 ochatokori 2020-08-19 21:39:12 +08:00 via Android arch 上的 electron 应用有很多都是用本地的 electeon 启动的 但是事实上开发者打包应用的时候还是要打包个 electron 进去 |
6 ochatokori 2020-08-19 21:41:44 +08:00 via Android 而且 electeon 也会有版本问题,这两年好像就更了 4 个大版,兼容性堪忧 |
7 timpaik OP @ochatokori arch 上的很多包确实是直接用了个脚本启动? 关于兼容性,我了解的不是很多,目前并不知道有什么向前不兼容的 api 、、 |
8 Kr98 2020-08-19 21:44:32 +08:00 你不是第一个这么想的,但这个想法一直无法落地。electron 周更,而且新版本有时会引入新 bug 或 breaking changes,基本不可能提供公用的核心。 |
9 Cbdy 2020-08-19 22:17:52 +08:00 via Android |
11 ZeoKarl 2020-08-19 22:39:09 +08:00 via iPhone 有 runtime 版本问题,一旦无法匹配,直接崩溃,而且是 c++层面的,debug 都费劲 |
12 BianSir 2020-08-19 22:42:18 +08:00 via iPhone 有想法,棒! |
14 timpaik OP |
15 cielpy 2020-08-20 00:37:25 +08:00 刚看了下 Electron 已经 11.x 了。。。 |
17 mgrddsj 2020-08-20 18:38:22 +08:00 via Android 之前好像有帖子讨论过这个问题。结果是会因为不同版本自建的兼容性问题,像 C++ 那样在用户电脑上装 N 个 Microsoft Visual C++ Redistributable,反而失去了 Electron 打包的便利。 |
19 timpaik OP 过了许久,现在再看看,还是 webview2 真香,用 tauri 还能调用 native |