Winterreisender / webview-nodejs

A Node.js binding to webview
Apache License 2.0
89 stars 10 forks source link

Is it correct to package it as an exe like this? #28

Closed wzj042 closed 2 months ago

wzj042 commented 2 months ago

Hello everyone,

I apologize for my limited knowledge of frontend technologies and hope someone can point out any potential mistakes in my current approach.

I am trying to develop a lightweight tool using Node.js that can be shared with users who only have a webview installed.

I have installed CMake and C++ BuildTool and run the code examples. My current issue is how to package the code as an executable file.

I found a method to package executable files using pkg, but I was surprised to find that the resulting file is still larger (around 40MB). Is this normal? Are there better packaging methods to reduce the application size?

Thank you for your assistance!

Clip_2024-09-23_21-08-35

Winterreisender commented 2 months ago

It's a quite normal case accoding to my knowledge. The nodejs runtime will at least cost about 30MB and some node packages will cost about 5MB, webview-nodejs itself, will only cost about 2MB. That means, a simple helloworld written in Node.js will cost at least 30MB, even with some optimizations like upx or pkg index.js --compress. It's possible in theory that you compile Node.js yourself and remove redundant code, but that's not practical. So if you wanna a extremly small JS program, without any Node.js functions, you can give neutralino.js a try. You'll get an excutable file less than 5MB

wzj042 commented 2 months ago

It's a quite normal case accoding to my knowledge. The nodejs runtime will at least cost about 30MB and some node packages will cost about 5MB, webview-nodejs itself, will only cost about 2MB. That means, a simple helloworld written in Node.js will cost at least 30MB, even with some optimizations like upx or pkg index.js --compress. It's possible in theory that you compile Node.js yourself and remove redundant code, but that's not practical. So if you wanna a extremly small JS program, without any Node.js functions, you can give neutralino.js a try. You'll get an excutable file less than 5MB

@Winterreisender Thank you very much for your prompt and helpful response to the issue. Now that I've reconfirmed the need, it solved my question!