Repository navigation
Conversation
Publish each prebuilt library of a release as its own package, `@matrix-org/matrix-sdk-crypto-nodejs-<platform>`, laid out in `npm/` by `napi create-npm-dir`. Each release build now also uploads its library as a workflow artifact; the publish job copies them into those packages with `napi artifacts` and publishes them with `napi prepublish`, which also lists them as `optionalDependencies` of the main package. The `index.js` that `napi build --platform` generates already loads the library from that package when there is no local build next to it. Remove `download-lib.js`, its `postinstall` hook, the dependencies it used, and the `--ignore-scripts` flags that only kept it from running. Signed-off-by: jdsika <carlo.van-driesten@vdl.digital>
jdsika
force-pushed
the
feat/per-platform-packages
branch
from
November 15, 2026 09:17
ba0aacf to
7bde151
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces
download-lib.jswith per-platform npm packages that contain the prebuilt library, as asked in #113. It follows the pattern of matrix-org/seshat#184, using the commands@napi-rs/cli(v2, already a dev dependency) has for this instead of custom scripts.How it works
npm/<platform>/holds one package per release target,@matrix-org/matrix-sdk-crypto-nodejs-<platform>, generated bynapi create-npm-dir -t .fromnapi.triplesinpackage.json, which now lists the 13 targetsrelease.ymlbuilds. Each setsos,cpuand, on Linux,libc, so package managers install only the matching one. The platform names are the onesdownload-lib.jsused (linux-x64-gnu,win32-arm64-msvc, ...).optionalDependenciesat its own version.napi prepublishwrites them intopackage.jsonwhen publishing, as seshat's publish job does withnpm pkg set, so the lockfile never refers to versions that are not published yet.index.jsdoes not change: the filenapi build --platformgenerates already loads./matrix-sdk-crypto.<platform>.nodeif present (a local build) and otherwise requires@matrix-org/matrix-sdk-crypto-nodejs-<platform>.versionscript runsnapi version, sopnpm version(step 3 of RELEASING.md) bumpsnpm/*/package.jsonin the same commit.download-lib.js, thepostinstallhook,node-downloader-helperandhttps-proxy-agentare removed, and so is--ignore-scripts, which only keptdownload-lib.jsfrom running (as the comment inci.ymlsaid). No dependency in the lockfile has an install script.Release workflow
.nodeto the draft GitHub release, as seshat kept doing, and now also uploads it as the workflow artifactbindings-<target>.npm/<platform>directory withnapi artifacts, and publishes those 13 packages withnapi prepublish --skip-gh-release(npm publishwithNPM_CONFIG_ACCESS=publicandNPM_CONFIG_PROVENANCE=true, matching the existing--access public --provenance). It then packs, uploads and publishes the main package as before.Before the first release with this change, the maintainers need to own the 13 new names on npmjs.com. The workflow publishes them like the main package, with npm trusted publishing and no token, so each needs
release.ymlof this repository as its trusted publisher. npm only accepts that for a package that exists, so each name needs one publish by hand first (a placeholder version is enough), then the trusted publisher setting on npmjs.com or withnpm trust github. The names are@matrix-org/matrix-sdk-crypto-nodejs-followed bydarwin-arm64,darwin-x64,linux-arm-gnueabihf,linux-arm64-gnu,linux-arm64-musl,linux-ia32-gnu,linux-riscv64-gnu,linux-s390x-gnu,linux-x64-gnu,linux-x64-musl,win32-arm64-msvc,win32-ia32-msvcandwin32-x64-msvc.Differences from seshat (matrix-org/seshat#184)
<platform>-<arch>[-<abi>]instead of<os>-<cpu>, because the generatedindex.jsrequires them and Linux has both gnu and musl builds.package.jsonfiles are committed, as napi-rs lays them out, instead of being written by the workflow.index.jstries a local build before the platform package (napi-rs's order; seshat tries the package first), so a local build such as one with tracing still wins undernpm link.Testing
pnpm lint, andpnpm test(9 suites, 67 tests) against a localpnpm release-buildon Linux x64. Itsindex.jsandindex.d.tsare byte-identical to the ones in the published 0.7.0 tarball.npmreplaced by a stub:napi artifactsplaced all 13 binaries, andnapi prepublishrannpm publishonce in each of the 13 directories with both settings and wrote the 13optionalDependencies.pnpm packof the main package then containsindex.js,index.d.tsand those dependencies, and nodownload-lib.js,npm/or.node.pnpm packofnpm/linux-x64-gnucontains the binary,package.jsonandREADME.md.npm install --offlineof both tarballs into an empty project loads the binary from the platform package. With the binary next toindex.jsinstead, it loads that; with neither, it fails withCannot find module '@matrix-org/matrix-sdk-crypto-nodejs-linux-x64-gnu'.pnpm version 0.8.0 -m "v%s"in a scratch repository commitspackage.jsonand all 13npm/*/package.jsonat 0.8.0.main. The release workflow itself has not run.The generated
index.jshas no case for Linux on ia32, so thelinux-ia32-gnubuild cannot be loaded through it. That is the same today and is not changed here.Resolves #113.