[chore] Decrease standalone binary size#1858
Conversation
ab30f16 to
8321cfe
Compare
8321cfe to
c6d435f
Compare
00982b0 to
1a75371
Compare
1a75371 to
60a5040
Compare
|
| + "node-v22.19.0-linux-arm64": "bf0b13343f044104e935e8c9581c1c8bbf4f70185fc49ee49a63c83be95e2b93", | ||
| + "node-v22.19.0-linux-x64": "f51476881e6af23347b4e8e0cc56e1aeffe6641e7523f2cac9601287ab3d00b4", | ||
| + "node-v22.19.0-macos-arm64": "83b21eb4f79caa516ac7638fcbbbedd9dd357756549dd61f69ee7d40f2d95e63", | ||
| + "node-v22.19.0-macos-x64": "fb493dbaced86bc65b19e04b5a325c89f470bc318720b0ab505a00cbb80ec039", | ||
| + "node-v22.19.0-win-x64": "8440fe844868085dce1eb363b819c982f56f650e789fd04aa8213ce9968f07c4" |
There was a problem hiding this comment.
The expected checksums for the binaries attached to this release: https://github.com/Drarig29/pkg-fetch/releases/tag/v1.0
| switch (_c.label) { | ||
| case 0: | ||
| - url = "https://github.com/yao-pkg/pkg-fetch/releases/download/".concat(tag, "/").concat(name); | ||
| + url = "https://github.com/Drarig29/pkg-fetch/releases/download/".concat(tag, "/").concat(name); |
There was a problem hiding this comment.
Point to the fork when downloading the binaries from release assets
| } | ||
| function satisfyingNodeVersion(nodeRange) { | ||
| - var versions = Object.keys(patches_json_1.default) | ||
| + var versions = ['v22.19.0'] |
There was a problem hiding this comment.
Hardcode the version that was used to build our prebuilt binaries
| { | ||
| "name": "@yao-pkg/pkg-fetch", | ||
| - "version": "3.5.24", | ||
| + "version": "1.0.0", |
There was a problem hiding this comment.
1.0.0 becomes 1.0, and it should point to the tag of the release we want to download assets from
| - if (argv.sea) { | ||
| - await (0, sea_1.default)(inputFin, { | ||
| - targets, | ||
| - signature: argv.signature, | ||
| - }); | ||
| - return; | ||
| - } |
There was a problem hiding this comment.
The current implementation of the --sea option in @yao-pkg/pkg skips the downloading of prebuilt binaries ("targets") with @yao-pkg/pkg-fetch – and directly downloads an official Node.js binary (without pkg's patches).
This patch moves that code down, after fetching targets with @yao-pkg/pkg-fetch so that we can fetch the binaries from our fork, using the other yarn patch.
| + if (target.fabricator) { | ||
| + return target.fabricator.binaryPath; | ||
| + } |
There was a problem hiding this comment.
Early return to use the fetched prebuilt binary instead of re-fetching an official Node.js binary.
| const IntlCollator = function () { | ||
| return { | ||
| // See https://nodejs.org/api/intl.html | ||
| compare: (a, b) => String(a).localeCompare(b), | ||
| } | ||
| } |
There was a problem hiding this comment.
The only requirement after using --with-intl=none is that the Intl global object isn't available anymore and trying to access it would throw a ReferenceError, so we need to add a shim to replace it.
What and why?
This PR patches
@yao-pkg/pkgand@yao-pkg/pkg-fetchto use precompiled binaries withoutIntlsupport with the--seaoption.See https://github.com/Drarig29/pkg-fetch#this-project-is-a-fork-used-by-datadogdatadog-ci-see-1858 for the big picture.
In the last version of datadog-ci we had standalone binaries based on Node.js 18, with a size of ~90MB. By moving to Node.js 22 without any optimization we would end up with ~125MB binaries.
With this PR, we have the best of both worlds: the upgrade to Node.js 22, and ~71MB binaries! 🎉
v3.20.0v3.21.0How?
Fork
@yao-pkg/pkg-fetch, prebuild Node.js binaries withoutIntlsupport and add patches in datadog-ci to use those prebuilt binaries.We could write our own scripts to download the prebuilt binaries and generate the SEA binary without importing
pkgor@yao-pkg/pkgat all, but this is more error-prone than tiny patches in the repo.Review checklist