Minify embedded lib/**/*.js for lite builds #53422
Closed
davidfiala
started this conversation in
Ideas
Replies: 1 comment
-
Theoretically, I suppose they could be minified, but as I understand it, saving approximately 6MB isn’t a goal of the project. While there might be other projects that reduce the Node.js binary, 6MB is still 6MB, and with the normal binary, it's not that much space to save. CC @nodejs/build to verify this. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm looking at improvements to cut down on the size of light builds of node. A minimalistic static node with --v8-lite-mode and no intl comes in at 41,476 KB. YMMV as I've trimmed a few other things out already such as https://github.com/orgs/nodejs/discussions/53421.
I was wondering about the js files in
lib
and whether they could in theory be minified.As an experiment, I used esbuild's minify flag on the directory without any other changes. It may or may not be safe, but it's just to start a conversation:
...saving about 1,688 KB (39% drop) in JS changes alone.
Relative to the original, stripped node binary, that delta theoretically saves us 4% in final binary size.
One disadvantage I can think of is source mapping for console error traces. For embedded environments, the trade-off is probably worth it (for me personally, it definitely is). We can preserve debugging info by storing source maps as a separate build artifact.
Here's an example of artifact sizes if we split out source maps:
I could imagine that such a minification could exist as a configure flag which triggers js2c (?) to behave differently.
What do folks think?
Thanks for your time!
Beta Was this translation helpful? Give feedback.
All reactions