Publish blit binary via npm (blit-bin)#66
Merged
Merged
Conversation
Add a blit-bin npm launcher plus per-platform blit-bin-<os>-<cpu>[-musl]
data packages generated from the existing release tarballs/zip, so the
host installs exactly one prebuilt binary through optionalDependencies.
The default export is the absolute path to the blit executable
(ffmpeg-static convention), so downstreams can:
import blit from "blit-bin";
spawn(blit, ["open"], { stdio: "inherit" });
Ships dual ESM/CJS entries, a blit-bin/resolve subpath, and .d.ts types.
A new publish-bin-npm release job builds and publishes these from the
artifacts the release already produces, using OIDC provenance.
Coverage
|
pcarrier
added a commit
that referenced
this pull request
Jun 12, 2026
## What
Rename the npm packages that ship the `blit` binary from the unscoped
`blit-bin` / `blit-bin-<platform>` to the **`@blit-sh`** scope, matching
the existing `@blit-sh/*` packages (`browser`, `core`, `react`,
`solid`).
| before | after |
| --- | --- |
| `blit-bin` | `@blit-sh/bin` |
| `blit-bin-linux-x64` | `@blit-sh/bin-linux-x64` |
| `blit-bin-linux-x64-musl` | `@blit-sh/bin-linux-x64-musl` |
| `blit-bin-linux-arm64[-musl]` | `@blit-sh/bin-linux-arm64[-musl]` |
| `blit-bin-darwin-arm64` | `@blit-sh/bin-darwin-arm64` |
| `blit-bin-win32-x64` | `@blit-sh/bin-win32-x64` |
The launcher still installs **exactly one** prebuilt binary for the host
via `optionalDependencies` + `os`/`cpu`/`libc` filters.
## Import API (unchanged shape)
Default export is the absolute path to the platform `blit` executable:
```js
import blit from "@blit-sh/bin";
import { spawn } from "node:child_process";
spawn(blit, ["open"], { stdio: "inherit" });
```
Identical in CommonJS (`require("@blit-sh/bin")`). Helpers remain
available as named exports and on `@blit-sh/bin/resolve`.
## Changes
- `git mv npm/blit-bin -> npm/bin`; rewrote package names across the
resolver, ESM/CJS entries, CLI, `.d.ts`, README, and both
`bin/*-npm-bin-packages` scripts.
- `release.yml` is untouched: the `publish-bin-npm` job already calls
the scripts by path and publishes with `--provenance --access public`
(scoped packages need `--access public`, already passed).
## Verified locally
- Generator emits `@blit-sh/bin` + 6 `@blit-sh/bin-<platform>` packages
into the nested `@blit-sh/` dir layout, with correct `os`/`cpu`/`libc`,
version pinning, and `optionalDependencies`.
- Scoped `node_modules/@blit-sh/*` resolution: ESM default import, CJS
`require`, `@blit-sh/bin/resolve` subpath, spawn, and CLI all work.
- Publisher walks the nested dirs in order (platform packages first,
launcher last).
- `prettier --check .` clean; `npm pack --dry-run` produces
`blit-sh-bin-<ver>.tgz` with the expected 8-file list.
Follow-up to #66 (now merged); branches off latest `main`.
pcarrier
added a commit
that referenced
this pull request
Jun 12, 2026
## What
Rename the npm packages that ship the `blit` binary from the unscoped
`blit-bin` / `blit-bin-<platform>` to the **`@blit-sh`** scope, matching
the existing `@blit-sh/*` packages (`browser`, `core`, `react`,
`solid`).
| before | after |
| --- | --- |
| `blit-bin` | `@blit-sh/bin` |
| `blit-bin-linux-x64` | `@blit-sh/bin-linux-x64` |
| `blit-bin-linux-x64-musl` | `@blit-sh/bin-linux-x64-musl` |
| `blit-bin-linux-arm64[-musl]` | `@blit-sh/bin-linux-arm64[-musl]` |
| `blit-bin-darwin-arm64` | `@blit-sh/bin-darwin-arm64` |
| `blit-bin-win32-x64` | `@blit-sh/bin-win32-x64` |
The launcher still installs **exactly one** prebuilt binary for the host
via `optionalDependencies` + `os`/`cpu`/`libc` filters.
## Import API (unchanged shape)
Default export is the absolute path to the platform `blit` executable:
```js
import blit from "@blit-sh/bin";
import { spawn } from "node:child_process";
spawn(blit, ["open"], { stdio: "inherit" });
```
Identical in CommonJS (`require("@blit-sh/bin")`). Helpers remain
available as named exports and on `@blit-sh/bin/resolve`.
## Changes
- `git mv npm/blit-bin -> npm/bin`; rewrote package names across the
resolver, ESM/CJS entries, CLI, `.d.ts`, README, and both
`bin/*-npm-bin-packages` scripts.
- `release.yml` is untouched: the `publish-bin-npm` job already calls
the scripts by path and publishes with `--provenance --access public`
(scoped packages need `--access public`, already passed).
## Verified locally
- Generator emits `@blit-sh/bin` + 6 `@blit-sh/bin-<platform>` packages
into the nested `@blit-sh/` dir layout, with correct `os`/`cpu`/`libc`,
version pinning, and `optionalDependencies`.
- Scoped `node_modules/@blit-sh/*` resolution: ESM default import, CJS
`require`, `@blit-sh/bin/resolve` subpath, spawn, and CLI all work.
- Publisher walks the nested dirs in order (platform packages first,
launcher last).
- `prettier --check .` clean; `npm pack --dry-run` produces
`blit-sh-bin-<ver>.tgz` with the expected 8-file list.
Follow-up to #66 (now merged); branches off latest `main`.
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.
What
Publish the
blitbinary to npm so it can be installed (npm i -g blit-bin) and bundled into downstream tools.This adds a thin
blit-binlauncher plus per-platformblit-bin-<os>-<cpu>[-musl]data packages. The launcher lists the platform packages asoptionalDependencieswithos/cpu/libcfilters, so npm installs exactly one prebuilt binary — the one matching the host — and nothing else.graph TD U["npm i blit-bin"] --> L["blit-bin launcher"] L -->|"optionalDependencies: os, cpu, libc"| P{"host"} P -->|"linux x64 glibc"| A["blit-bin-linux-x64"] P -->|"linux x64 musl"| B["blit-bin-linux-x64-musl"] P -->|"linux arm64"| C["blit-bin-linux-arm64 (plus -musl)"] P -->|"darwin arm64"| D["blit-bin-darwin-arm64"] P -->|"win32 x64"| E["blit-bin-win32-x64"] L -.->|"bin launcher execs"| AImport API
The default export is the absolute filesystem path to the
blitexecutable (theffmpeg-static/@esbuild/*convention), so downstreams can spawn it:Identical in CommonJS (
const blit = require("blit-bin")). Resolution happens eagerly at import and throws an actionable error if the matching optional package was omitted. Lower-level helpers (binaryPath,binaryName,candidatePackages,isMusl) are available as named exports and on theblit-bin/resolvesubpath. Ships dual ESM (index.mjs) + CJS (index.js) with anexportsmap andindex.d.tstyping the default asstring.Pipeline
bin/build-npm-bin-packagesrepackages the existing release artifacts (blit_<ver>_<os>[-musl]_<arch>.tar.gz+blit_<ver>_windows_x86_64.zip) into the per-platform packages and the launcher, pinningoptionalDependenciesto the release version.bin/publish-npm-bin-packagespublishes platform packages first, launcher last.publish-bin-npmjob inrelease.yml(needsrelease) downloadstarballs-*+windows-x86_64and publishes with--provenance --access public(OIDC — same tokenless setup as the existing@blit-sh/*job).The platform matrix tracks exactly what CI builds today (linux x64/arm64 glibc+musl, darwin arm64, win32 x64); the generator auto-discovers any artifact, so adding e.g. darwin-x64 later needs no script change.
Verified locally
os/cpu/libcand version pinning.import blit fromand CJSrequireboth return the path and spawn the binary; CLI (bin/blit) works with exit-code/signal passthrough.npm pack --dry-runfile lists clean;tsc(nodenext) confirms default isstringand the/resolvesubpath resolves;release.ymlparses and artifact names match the build workflows.