Skip to content

userid 2.0: prebuilt binaries, TypeScript, ESM, installs everywhere - #9

Merged
cinderblock merged 15 commits into
masterfrom
modernize
Nov 11, 2026
Merged

cinderblock merged 15 commits into
masterfrom
modernize

Conversation

@cinderblock

Copy link
Copy Markdown
Owner

userid 2.0: prebuilt binaries, TypeScript, ES modules, and a clean install everywhere. The full list is in CHANGELOG.md.

What changes for users

  • No compiler, no install script. The package ships prebuilt binaries for Linux (x64, arm64, armv7, ppc64le, s390x on glibc 2.31+; x64, arm64 on musl), macOS (arm64, x64), and FreeBSD (x64). npm, pnpm 11+ and Bun install it with no build step and no build approval.
  • ES module + CommonJS entry points, with TypeScript types for both (checked by publint and are-the-types-wrong).
  • Installs on Windows: isSupported is false, and every lookup throws ERR_USERID_UNSUPPORTED_PLATFORM.
  • Safe from worker threads (reentrant *_r lookups), with errors that carry codes (ERR_USERID_NOT_FOUND, EIO, ...).
  • Breaking: Node.js ≥ 22.12, ids validated (RangeError), exports map, no build-from-source fallback on install. See the migration notes in the changelog.

How it's built and tested

  • native/userid.cc is a rewrite (node-addon-api 8, Node-API 8). The TypeScript wrapper lives in lib/. Tests use node:test, run by Node's own type stripping, and compare against id.
  • CI runs 42 jobs:
    • Node 22/24/26 on Linux x64, Linux arm64 and macOS, building from source.
    • Windows, FreeBSD, and checks: format, spelling, types, clang-tidy, package shape.
    • 10 prebuilds, built in glibc 2.31 and Alpine containers.
    • The packed tarball, installed by npm, pnpm and Bun on Linux, macOS (arm64 and Intel), Windows, Alpine, and emulated armv7, ppc64le and s390x, with the full test suite run against the installed copy.
  • release.yml publishes that exact tarball with provenance via npm trusted publishing when a v* tag is pushed.
  • Dependabot (Bun + Actions) replaces the old weekly auto-update-and-publish job.

The prebuild matrix started from @matthewh's #8 (credited as co-author on the CI commit). Planning notes: plans/triage-and-modernize.md.

🤖 Generated with Claude Code

cinderblock and others added 15 commits November 9, 2026 19:31
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n Windows

Native (src/userid.cc, replaces six files):
- node-addon-api 8, Node-API 8, so one binary loads on every Node.js version
- reentrant *_r lookups with growing buffers: safe from worker threads
- ids validated as integers in [0, 2^32) (RangeError); names with null
  bytes rejected; gids always unsigned and never duplicated
- not-found errors carry code ERR_USERID_NOT_FOUND; system errors carry
  errno + syscall, which the wrapper turns into Node-style code/message

JavaScript (lib/, compiled to dist/):
- TypeScript, with ES module and CommonJS entry points via an exports map
- loads prebuilt binaries via node-gyp-build (drops bindings)
- Windows: installs without building; isSupported is false and every
  lookup throws ERR_USERID_UNSUPPORTED_PLATFORM

Tooling: Bun (bun.lock) for install, node:test with Node's type
stripping (replaces mocha/should/ts-node/nyc), a curated clang-tidy
config that fails on warnings, publint + attw for the package shape.
Node.js >= 22.12.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Prebuilds (prebuildify) for linux x64/arm64 (glibc 2.31 and musl),
linux armv7, darwin arm64/x64, and freebsd x64, packed into one tarball.
That tarball is installed by npm, pnpm and Bun on Linux, macOS (arm64
and Intel), Windows, Alpine and armv7, with no compiler, and the full
test suite runs against the installed copy. Bun matters most: it skips
dependency install scripts, so it only works with prebuilds.

The release workflow now publishes that exact tarball. Dependabot
replaces the old weekly update job.

Based on the prebuild matrix in #8.

Co-Authored-By: Matthew Hershberger <247648+matthewh@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pnpm 11+ fails `pnpm add` (ERR_PNPM_IGNORED_BUILDS) for any dependency
with an install script, even one that does nothing because a prebuild
exists, and treats a shipped binding.gyp the same way. So the package
now ships only dist/ and prebuilds/:

- no install script, gypfile false; node-addon-api is a dev dependency
- the native sources and binding.gyp live in native/, so no package
  manager auto-builds the repo root (Bun did, breaking Windows dev)
- build:native is prebuildify, so dev, CI and releases build one way
- platforms without a prebuild get ERR_USERID_NO_PREBUILT_BINARY with
  a pointer to building from source; the smoke test checks that
- new prebuilds and emulated consumer tests: linux ppc64le, s390x

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s prebuildify headers

There's no node:22-bullseye image for ppc64le or s390x (and no Node.js
image at all for s390x), so those build in debian:bullseye with the
official Node.js 22 tarball (scripts/ci-install-node.sh), keeping glibc
2.31 like the other Linux prebuilds.

clang-tidy looked for headers in node-gyp's cache, but prebuildify
downloads them to its own (tmpdir/prebuildify), for a version it picks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Debian 11's Docker images have dropped ppc64le and s390x too. Ubuntu
20.04 has both, with the same glibc 2.31.

The runner's clang-tidy (newer than 18) adds misc-const-correctness,
which misfires on an out-parameter of the *_r lookups (disabled), and
prefers #ifdef (done).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
prebuildify defaults to the newest Node.js headers (26.0.0), whose
common.gypi passes -std=gnu++20, which Ubuntu 20.04's gcc 9 rejects.
Under Node-API the binary is the same either way, so pin the target to
our engines floor: reproducible, and kinder to older compilers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Static libstdc++ made each Linux binary ~5x bigger (316 kB vs 60 kB on
x64, an 824 kB tarball) and less portable, not more: it pulled in the
build machine's newest glibc symbols. Dynamically linked, the binary
needs only GLIBC_2.14 and GLIBCXX_3.4.21, far older than what Node.js
22 itself requires.

scripts/check-prebuilds.sh reads each glibc prebuild's symbol versions
(readelf, any architecture) and fails CI past Node.js 22's own floor
(glibc 2.28, GLIBCXX 3.4.25). The README now says glibc 2.28+.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cinderblock
cinderblock merged commit 1dc988f into master Nov 11, 2026
84 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant