javascriptdllsizenode-webkit

How can I share nw.js binaries with apps in subfolders?


So I am running into the following problem: My project (this one) relies on two different nw.js apps bundled using web2exe. One of them is used for settings, the other one is GUI-less and supposed to run in the background on startup. The second app also depends on nw for things like showing a tray icon and hiding the window which would otherwise need to happen through platform specific scripts like batchfiles or shell scripts. This solution works fine, but due to the system needing to access some plain files in the tree I can't compress the executables. And even if I could, the biggest files are dlls and locale files. Bundling two seperate, uncompressed nw apps with additional node modules leads to an enourmous file size of around 800mb, which is just completely unrealistic for what my app is trying to accomplish.

I was thinking about using another Framework like Neutralinojs, but that would mean having to rewrite code and loosing some nw specific functionality in the process. What I'm more interested in would be sharing nw files between my two apps. The second one is in a subfolder of the first one. Most nw files, except for the executable itself, are exact duplicates of ones found in the root nw directory. Especially sharing the nw.dll and locales folder between them would already cut the size down by around 200mb.

I've been looking for ways to do that, but I couldn't really find any good ones as of now. Maybe there's a solution here that I'm missing. Another solution that I could imagine would be using some kind of smaller subset or reimplementation of nw using native webview. Maybe there's something like that out there, but I haven't found it yet.


Solution

  • The easiest solution is to simply combine these into a single app.

    1. Change FelizJueves' main in package.json to a JS file instead of an HTML file.
    2. Have that JS script be your background process. Don't open a window, just do everything you currently have in FelizCheck.
    3. In that JS script, listen for the open event: https://nwjs.readthedocs.io/en/latest/References/App/#event-openargs
    4. In the open event handler, use nw.Window.open() to show the window (FelizJueves.html). This event fires when somebody tries to launch the already-running app. So, first launch just starts the background checker. Second launch brings up the UI window.