Tuesday, August 2, 2016

Nw.js system-wide installation

About a year ago I talked here on this blog about the nw.js framework, that allows to build desktop applications using web languages and technologies. In that post, I pointed out that in my opinion an annoying problem with this framework is the size of the binaries to distribute (about 60MB for a very simple application) when the official packaging method is used.
I thought about a workaround for this and I designed an alternative packaging method where the nw.js runtime files are installed globally on the system, like it's usually done with other application frameworks such as Java or .NET/Mono. I then built some tools to manage multiple system-wide installed versions of nw.js and to build installers (for Windows) and packages (for Linux distributions) for applications that use this packaging method. The produced installers/packages won't include the nw.js runtime, but will download it (in the correct version) during the installation only if the user hasn't a compatible version installed yet; the files are downloaded from the official nw.js website. Everything is released under the open source MIT license; here is the repository with more detailed documentation in the README. Everyone is welcome to contribute; if you have any suggestion or you found a bug, comment here on this post or file an issue. Alternatively, you can fork the repository and apply your improvement, then open a pull request.
Deploying nw.js applications using this method is made simple by the command line tool, written in Javascript; actually it can build Windows installers (based on NSIS) and .deb and .rpm packages for Linux distributions (Debian-like ones and RPM-based ones, using fpm). You can get the tool from npm (global installation is recommended since this is a cli tool; use npm install -g nw-global-build). See the README for documentation.

A screenshot taken on Windows during the installation of a simple nw.js app. The nw.js files are being downloaded.
On this other repository you can find an example application which is packaged with nw.js-global-install; on the Travis-CI log you can see the output of the build tool.

I admit there are some limitations with this packaging method, because people working on big and/or commercially-licensed applications probably don't want their product to rely on 3rd party tools and will still prefer to ship a full nw.js distribution together with the application, so it's self-contained and they will avoid problems with user support. However I think nw.js-global-install can be useful for smaller and/or open source projects where it's common to use 3rd party libraries and tools and support isn't a big issue.

No comments:

Post a Comment