How to avoid large distributions with pkg?
We build applications with Node and pkg, then build a debian file around the generated binary, and distribute that debian file on a repo managed with aptly, where it will get downloaded 50k times or more to our own equipment. In the past, we used PHP and just distributed the source to the devices where it ran with the native PHP installation, so the deb files were only a few KB in the end. Now, the company doesn't want source code being distributed, and we've long since moved to NodeJS anyway. vercel/pkg works, but even after the compression in the debian file, the deb ends up 18-19MB.
Does anybody know a good way to bundle the bytecode up in some way that can run directly on a Linux system but have the patched Node binary distributed separately? If we're distributing 5 apps to 50K devices, and everything is running on the same Node 16.x, it seems awfully wasteful to send 5x 18-19MB to each device, and then do that again for each release cycle.
5 comments · 67% upvoted · other discussions
Maybe webpack bundle + bytenode can help.
https://github.com/herberttn/bytenode-webpack-plugin
jackdbd 2 points · Oct 2022
I'm curious. I have never used bytenode. With bytenode you get V8 Ignition bytecode right? So no need to package the Node.js app with pkg, nexe, etc. Right?
Ark42 [OP] 1 points · Oct 2022
Looks like there's some issues with bytenode and toString(), and the linked thread specifically mentions fast-json-stringify, which we use. I'm also not sure where the node binary comes from in this case? With pkg, the resulting binaries work on all our systems (Ubuntu 14.04 and every release after that, all mixed together..) and these older systems don't even have Node 16 normally available to install separately.